public static void setup_imported_ui_scrollview(Transform t) { var list = new List <ScrollRect>(); HierarchyUtility.TraverseComponent <ScrollRect>(t, i => { list.Add(i); }); foreach (var i in list) { var scrollviewevent = ComponentUtil.AddComponentIfNotExist <UIScrollViewEvent>(i.gameObject); i.onValueChanged.AddListener(scrollviewevent.Change); } }
public static void setup_imported_ui_slider(Transform t) { var list = new List <Slider>(); HierarchyUtility.TraverseComponent <Slider>(t, i => { list.Add(i); }); foreach (var i in list) { var slider = ComponentUtil.AddComponentIfNotExist <UISliderEvent>(i.gameObject); i.onValueChanged.AddListener(slider.Change); } }
public static void setup_imported_ui_toggle(Transform t) { var list = new List <Toggle>(); HierarchyUtility.TraverseComponent <Toggle>(t, i => { list.Add(i); }); foreach (var i in list) { var but = ComponentUtil.AddComponentIfNotExist <UIToggleEvent>(i.gameObject); i.onValueChanged.AddListener(but.PushDown); } }
public static void setup_imported_ui_button(Transform t) { var list = new List <Button>(); HierarchyUtility.TraverseComponent <Button>(t, i => { list.Add(i); }); foreach (var i in list) { var but = ComponentUtil.AddComponentIfNotExist <UIButtonEvent>(i.gameObject); i.onClick.AddListener(but.PushDown); } }
public static void setup_imported_ui_scrollbar(Transform t, object control = null) { var list = new List <Scrollbar>(); HierarchyUtility.TraverseComponent <Scrollbar>(t, i => { list.Add(i); }); foreach (var i in list) { var scrollbar = ComponentUtil.AddComponentIfNotExist <UIScrollbarEvent>(i.gameObject); scrollbar.m_control = control; i.onValueChanged.AddListener(scrollbar.Change); } }
public static void setup_imported_ui_inputfield(Transform t) { var list = new List <InputField>(); HierarchyUtility.TraverseComponent <InputField>(t, i => { list.Add(i); }); foreach (var i in list) { var inputfield = ComponentUtil.AddComponentIfNotExist <UIInputFieldEvent>(i.gameObject); i.onValueChanged.AddListener(inputfield.Change); i.onEndEdit.AddListener(inputfield.End); } }
private void Start() { m_templates = new List <Canvas>(); m_templates.Add(m_temaplate_base); HierarchyUtility.TraverseComponent <Canvas>( m_add_from_unitypackage.transform, i => { var s = i.ToString(); Debug.Log(s); m_templates.Add(i); } ); m_sm = new UITest01Control(); }
public static void setup_imported_ui_button(Transform t, object control = null) { var list = new List <Button>(); HierarchyUtility.TraverseComponent <Button>(t, i => { list.Add(i); }); foreach (var i in list) { var et = ComponentUtil.AddComponentIfNotExist <EventTrigger>(i.gameObject); // Use Event Trigger! (Default Event is not safe under static object.) var but = ComponentUtil.AddComponentIfNotExist <UIButtonEvent>(i.gameObject); but.m_control = control; var entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerDown; entry.callback.AddListener((data) => { but.PushDown(); }); et.triggers.Add(entry); } }
static void MakeSpriteInfo() { var scene1file = "Assets/public/Testbed/UI/ui_work.unity"; // load EditorSceneManager.OpenScene(scene1file); // template検索 var tmplgo = HierarchyUtility.FindGameObjectByUncPath(null, "UI/template"); Debug.Log("target :" + HierarchyUtility.GetAbsoluteNodePath(tmplgo)); HierarchyUtility.TraverseComponent <Image>(tmplgo.transform, c => { if (c.sprite == null) { Debug.Log(c.name); return; } GameObject sprite_go = null; for (var i = 0; i < c.transform.childCount; i++) { var ct = c.transform.GetChild(i); if (ct.name.StartsWith("*sprite=" + c.name + ":")) { sprite_go = ct.gameObject; break; } } if (sprite_go == null) { sprite_go = new GameObject(); } sprite_go.name = "*sprite=" + c.name + ":" + c.sprite.name; sprite_go.transform.parent = c.transform; sprite_go.transform.localPosition = Vector3.zero; sprite_go.transform.localRotation = Quaternion.identity; sprite_go.transform.localScale = Vector3.one; }); }
public static void SetSprite(RectTransform rt, UnityEngine.Sprite s, string name = null) { UnityEngine.UI.Image tc = null; HierarchyUtility.TraverseComponent <UnityEngine.UI.Image>(rt.transform, i => { if (tc != null) { return; } var b = true; if (name != null) { b = (i.name == name); } if (b) { tc = i; } }); if (tc != null) { tc.sprite = s; } }
public static void SetText(RectTransform rt, string s, string name = null) { UnityEngine.UI.Text tc = null; HierarchyUtility.TraverseComponent <UnityEngine.UI.Text>(rt.transform, i => { if (tc != null) { return; } var b = true; if (name != null) { b = (i.name == name); } if (b) { tc = i; } }); if (tc != null) { tc.text = s; } }