Beispiel #1
0
    public virtual T AttachRenderTarget <T>(ResourceRenderTarget obj, Resource.ResourceGroup rg) where T : UnityEngine.UI.Graphic
    {
        var target = obj.GetComponent <ResourceRenderTarget>();

        target.renderer      = this;
        target.resourceGroup = rg;
        return(null);
    }
Beispiel #2
0
    public void SetTarget(Resource.ResourceGroup rg)
    {
        transform.localScale = new Vector3(rg.Scale, rg.Scale, rg.Scale);
        RectTransform rect = GetComponent <RectTransform>();

        rect.anchoredPosition = rect.anchoredPosition + new Vector2(rg.XAxis, rg.YAxis);
        rect.sizeDelta        = new Vector2(rect.sizeDelta.x * rg.Scale, rect.sizeDelta.y * rg.Scale);
        transform.SetSiblingIndex(renderer.Priority * rg.Priority);
    }
Beispiel #3
0
 public void ReFlushComponent(CommonResourceRenderer renderer, Resource.ResourceGroup rg, Transform trans)
 {
     for (int i = 0; i < trans.childCount; i++)
     {
         var target = trans.GetChild(i).GetComponent <ResourceRenderTarget>();
         if (target != null)
         {
             if (target.renderer == renderer && target.resourceGroup == rg)
             {
                 Destroy(trans.GetChild(i).gameObject);
             }
         }
     }
 }
Beispiel #4
0
    public override T AttachRenderTarget <T>(ResourceRenderTarget target, Resource.ResourceGroup rg)
    {
        base.AttachRenderTarget <T>(target, rg);
        System.Type type = Content.GetType();
        var         dst  = target.GetComponent(type) as T;

        if (!dst)
        {
            dst = target.gameObject.AddComponent(type) as T;
        }

        var fields = type.GetFields();

        foreach (var field in fields)
        {
            if (field.IsStatic)
            {
                continue;
            }
            field.SetValue(dst, field.GetValue(Content));
        }

        var props = type.GetProperties();

        foreach (var prop in props)
        {
            if (!prop.CanWrite || !prop.CanWrite || prop.Name == "name")
            {
                continue;
            }
            prop.SetValue(dst, prop.GetValue(Content, null), null);
        }
        target.transform.localPosition = Vector3.zero;
        RectTransform rect = target.GetComponent <RectTransform>();

        rect.anchoredPosition = rectTranfrom.anchoredPosition;
        var cont = target.gameObject.AddComponent <ContentSizeFitter> ();

        cont.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
        cont.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
        target.SetTarget(rg);
        return(dst);
    }