Example #1
0
        static bool EqualComponent(ICuiComponent e1, ICuiComponent e2)
        {
            if (e1.Type != e2.Type)
            {
                return(false);
            }
            switch (e1.Type)
            {
            case "RectTransform":
                return(EqualComponent((CuiRectTransformComponent)e1, (CuiRectTransformComponent)e2));

            case "UnityEngine.UI.RawImage":
                return(EqualComponent((CuiRawImageComponent)e1, (CuiRawImageComponent)e2));

            case "UnityEngine.UI.Text":
                return(EqualComponent((CuiTextComponent)e1, (CuiTextComponent)e2));

            case "UnityEngine.UI.Image":
                return(EqualComponent((CuiImageComponent)e1, (CuiImageComponent)e2));

            case "UnityEngine.UI.Button":
                return(EqualComponent((CuiButtonComponent)e1, (CuiButtonComponent)e2));

            case "UnityEngine.UI.Outline":
                return(EqualComponent((CuiOutlineComponent)e1, (CuiOutlineComponent)e2));
            }
            return(false);
        }
Example #2
0
    public void LoadCuiComponent(ICuiComponent cuiComponent)
    {
        var cuiComponentType = cuiComponent.GetType();
        var componentType    = BaseComponent.GetComponentType(cuiComponentType);

        if (Components.Any(c => c.GetType() == cuiComponentType))
        {
            ((BaseComponent)GetComponent(componentType)).LoadInternal(cuiComponent);
            return;
        }
        Components.Add(cuiComponent);
        var component = (BaseComponent)gameObject.AddComponent(componentType);

        component.LoadInternal(cuiComponent);
    }
Example #3
0
 public abstract void LoadInternal(ICuiComponent component);