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); }
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); }
public abstract void LoadInternal(ICuiComponent component);