示例#1
0
 static void Update()
 {
     time += Time.deltaTime;
     if (time > 1)
     {
         time = 0;
         var objs = SceneAsset.FindObjectsOfType(typeof(UICompositeHelp));
         if (objs != null)
         {
             for (int i = 0; i < objs.Length; i++)
             {
                 var obj = objs[i] as UICompositeHelp;
                 if (obj != null)
                 {
                     obj.Refresh();
                 }
             }
         }
         objs = SceneAsset.FindObjectsOfType(typeof(HCanvas));
         if (objs != null)
         {
             for (int i = 0; i < objs.Length; i++)
             {
                 var obj = objs[i] as HCanvas;
                 if (obj != null)
                 {
                     obj.Refresh();
                 }
             }
         }
     }
 }
示例#2
0
        //TabManager[] allController;

        public override void OnInspectorGUI()
        {
            TabManager[] allControllers;
            allControllers = SceneAsset.FindObjectsOfType <TabManager>();
            foreach (TabManager tm in allControllers)
            {
                //if more than one tab is active, or the number of children doesn't match up, fix it.
                if (tm.CountActivePanels() != 1 || Helper.GetChildren(tm.TabPanels).Count != tm.panels.Count)
                {
                    tm.ReNumberTabs();
                    tm.SwitchToTab(tm.currentTab, false);
                }
                //catches undo Move
                if (tm.TabPanelIndexesMatch() == false)
                {
                    tm.SetTabsIndexViaPanels();
                    tm.ReNumberTabs();
                    tm.SwitchToTab(tm.currentTab, false);
                }
            }

            base.OnInspectorGUI();
            TabUtilMenu tabum = (TabUtilMenu)target;

            //buttons for adding a tab at the beginning or end of the tabs
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Beginning Tab", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tabum.TabManager.AddTabBegin();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add Tab at End", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tabum.TabManager.AddTabEnd();
            }
            GUILayout.EndHorizontal();

            //buttons for removing a tab at the beginning or end of the tabs
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Remove First Tab", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tabum.TabManager.RemoveTabBegin();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Remove Last Tab", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tabum.TabManager.RemoveTabEnd();
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Use these buttons to add and remove tabs.\nDo NOT do it manually!\nClick on an individual tab for more options.");

            //give the user the option to renumber the tabs
            if (GUILayout.Button("Force Renumber and Switch"))
            {
                tabum.TabManager.ReNumberTabs();
                tabum.TabManager.SwitchToTab(tabum.TabManager.currentTab, false);
            }
            GUILayout.Label("Use Force Renumber if something \ngoes wonky, like an object's name not \nmatching it's tab number.");
        }
示例#3
0
 static void Update()
 {
     if (Application.isPlaying)
     {
         return;
     }
     if (EditorApplication.isCompiling)
     {
         UIElement.DisposeAll();
     }
     time += Time.deltaTime;
     if (time > 1)
     {
         time = 0;
         var sys = SceneAsset.FindObjectsOfType(typeof(UISystem));
         if (sys != null)
         {
             if (sys.Length > 0)
             {
                 (sys[0] as UISystem).OverCamera();
             }
         }
         var objs = SceneAsset.FindObjectsOfType(typeof(UIHelper));
         if (objs != null)
         {
             for (int i = 0; i < objs.Length; i++)
             {
                 var obj = objs[i] as UIHelper;
                 if (obj != null)
                 {
                     obj.Refresh();
                 }
             }
         }
         objs = SceneAsset.FindObjectsOfType(typeof(HGUIRender));
         if (objs != null)
         {
             for (int i = 0; i < objs.Length; i++)
             {
                 var obj = objs[i] as HGUIRender;
                 if (obj != null)
                 {
                     if (obj.OldUI != null)
                     {
                         obj.OldUI.MakeContext();
                         obj.canvas = obj.OldUI.Content;
                         UIElement.ResizeChild(obj.canvas);
                         MakeContext(obj.canvas);
                     }
                     obj.Refresh();
                 }
             }
         }
     }
 }
示例#4
0
    static public void AddUISystem(MenuCommand menuCommand)
    {
        var ui = SceneAsset.FindObjectsOfType(typeof(huqiang.Core.HGUI.UISystem));

        if (ui != null)
        {
            if (ui.Length > 0)
            {
                Debug.Log("场景中已存在");
                return;
            }
        }
        new GameObject("UISystem", typeof(huqiang.Core.HGUI.UISystem));
    }
示例#5
0
    public static void ReloadScripts()
    {
        var objs = SceneAsset.FindObjectsOfType(typeof(huqiang.Helper.HGUI.HCanvas));

        if (objs != null)
        {
            for (int i = 0; i < objs.Length; i++)
            {
                var obj = objs[i] as huqiang.Helper.HGUI.HCanvas;
                //if (obj != null)
                //    obj.Refresh();
            }
        }
    }
    public static void ReloadScripts()
    {
        var objs = SceneAsset.FindObjectsOfType(typeof(HCanvas));

        if (objs != null)
        {
            for (int i = 0; i < objs.Length; i++)
            {
                var obj = objs[i] as HCanvas;
                if (obj != null)
                {
                    obj.Refresh();
                }
            }
        }
    }
示例#7
0
    static public void AddCanvas(MenuCommand menuCommand)
    {
        GameObject parent = menuCommand.context as GameObject;
        var        go     = new GameObject("Canvas", typeof(HCanvas));
        var        trans  = go.transform;

        trans.localPosition = Vector3.zero;
        trans.localScale    = Vector3.one;
        trans.localRotation = Quaternion.identity;
        var ui = SceneAsset.FindObjectsOfType(typeof(huqiang.Core.HGUI.UISystem));//GameObject.FindObjectOfType<huqiang.Core.HGUI.UISystem>();

        if (ui == null)
        {
            new GameObject("UISystem", typeof(huqiang.Core.HGUI.UISystem));
        }
    }
示例#8
0
    void OnGUI()
    {
        GUILayout.Label("Fix all font and text in current scene");
        GUILayout.Toggle(true, "Don't change size");
        font = (TMP_FontAsset)EditorGUILayout.ObjectField(font, typeof(TMP_FontAsset), true);
        if (GUILayout.Button("Fix now"))
        {
            if (font != null)
            {
                int counter = 0;
                foreach (TextMeshProUGUI obj in SceneAsset.FindObjectsOfType <TextMeshProUGUI>())
                {
                    if (obj.font != font)
                    {
                        counter++;
                        obj.font = font;
                    }
                }
                //foreach (Text obj in SceneAsset.FindObjectsOfType<Text>())
                //{
                //    try
                //    {
                //        GameObject att = obj.gameObject;
                //        RectTransform oldrt = att.GetComponent<RectTransform>();
                //        RectTransform rt = oldrt.GetCopyOf(new RectTransform());
                //        DestroyImmediate(obj);
                //        DestroyImmediate(att.GetComponent<CanvasRenderer>());
                //        att.AddComponent<TextMeshProUGUI>();
                //        att.GetComponent<TextMeshProUGUI>().font = font;
                //        oldrt = rt.GetCopyOf(new RectTransform());
                //    }
                //    catch { }
                //    counter++;

                //}
                Debug.Log(counter + " item(s) had been fixed!");
            }
        }
    }
示例#9
0
        public override void OnInspectorGUI()
        {
            Tab tab = (Tab)target;

            TabManager[] allControllers;
            allControllers = SceneAsset.FindObjectsOfType <TabManager>();
            foreach (TabManager tm in allControllers)
            {
                //if more than one tab is active, or the number of children doesn't match up, fix it.
                if (tm.CountActivePanels() != 1 || Helper.GetChildren(tm.TabPanels).Count != tm.panels.Count)
                {
                    tm.ReNumberTabs();
                    tm.SwitchToTab(tm.currentTab, false);
                }
                //catches undo Move
                if (tm.TabPanelIndexesMatch() == false)
                {
                    tm.SetTabsIndexViaPanels();
                    tm.ReNumberTabs();
                    tm.SwitchToTab(tm.currentTab, false);
                }
            }

            base.OnInspectorGUI();
            //button for selecting the current tab
            if (GUILayout.Button("Select Tab"))
            {
                tab.TabManager().SwitchToTab(tab.GetComponent <Tab>().GetTab());
            }

            //button for removing the current tab
            if (GUILayout.Button("Remove Tab"))
            {
                tab.TabManager().RemoveTab(tab.GetComponent <Tab>().GetTab());
            }

            //buttons for adding a tab before or after the current one
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Insert Tab Before", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tab.TabManager().InsertTab(tab.GetTab());
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Insert Tab After", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tab.TabManager().InsertTab(tab.GetTab() + 1);
            }
            GUILayout.EndHorizontal();

            //buttons for moving a tab up or down in the list
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Move Tab Up", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tab.TabManager().MoveTabUp(tab.GetTab());
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Move Tab Down", GUILayout.Width(Screen.width / 2 - 11)))
            {
                tab.TabManager().MoveTabDown(tab.GetTab());
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Use these buttons to add, remove, and move tabs.\nDo NOT do it manually");
        }
示例#10
0
 private void FindAllTexts()
 {
     allTexts = SceneAsset.FindObjectsOfType <Text> ();
 }