public static T CreateUI <T>(GameObject _go) where T : UIContainer { UIContainer ui = null; if (typeof(T) == typeof(UIContainer)) { ui = new UIContainer(_go); } else if (typeof(T) == typeof(UIButton)) { ui = new UIButton(_go); } else if (typeof(T) == typeof(UIEventListener)) { ui = new UIEventListener(_go); } else if (typeof(T) == typeof(UIImage)) { ui = new UIImage(_go); } else if (typeof(T) == typeof(UIInput)) { ui = new UIInput(_go); } else if (typeof(T) == typeof(UIText)) { ui = new UIText(_go); } else if (typeof(T) == typeof(UITexture)) { ui = new UITexture(_go); } return(ui as T); }
public static T CreateUI <T>(Object _obj) where T : UIContainer { UIContainer ui = null; if (typeof(T) == typeof(UIContainer)) { ui = new UIContainer(_obj as GameObject); } else if (typeof(T) == typeof(UIButton)) { ui = new UIButton(_obj as Button); } else if (typeof(T) == typeof(UIEventListener)) { ui = new UIEventListener(_obj as GameObject); } else if (typeof(T) == typeof(UIImage)) { ui = new UIImage(_obj as Image); } else if (typeof(T) == typeof(UIInput)) { ui = new UIInput(_obj as InputField); } else if (typeof(T) == typeof(UIText)) { ui = new UIText(_obj as Text); } else if (typeof(T) == typeof(UITexture)) { ui = new UITexture(_obj as RawImage); } if (ui != null) { return(ui as T); } return(null); }
public static UIContainer CreateUIContainer(Object _obj) { UIContainer ui = CreateUI <UIContainer>(_obj); return(ui); }