示例#1
0
        private bool DrawTextMod()
        {
            bool changed = false;
            int  row     = grid.rowCount;
            int  col     = grid.columnCount;

            mod = EditorGUILayout.Foldout(mod, "Text Mod");
            if (mod)
            {
                EditorGUI.indentLevel += 2;
                for (int r = 0; r < row; r++)
                {
                    EditorGUILayout.BeginHorizontal();
                    for (int c = 0; c < col; c++)
                    {
                        UITableCell cell = grid.GetCell(r, c);
                        UILabel     l    = cell != null?cell.GetComponentInChildren <UILabel>() : null;

                        string s = l != null? l.text: "";
                        if (EditorGUIUtil.TextField(null, ref s, GUILayout.Width(70)) && l != null)
                        {
                            l.SetText(s);
                            changed = true;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.indentLevel -= 2;
            }
            return(changed);
        }
示例#2
0
        protected override bool OnInspectorGUI(RenderQueueElement info, int i)
        {
            float width   = GetWidth();
            bool  changed = false;

            changed |= EditorGUIUtil.TextField(null, ref info.name, GUILayout.MinWidth(width * 0.5F));
            changed |= EditorGUIUtil.IntField(null, ref info.value, GUILayout.MinWidth(width * 0.3F));
            return(changed);
        }
示例#3
0
 private void DrawFindLexiconGUI()
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUIUtil.TextField("Lexicon Keys", ref lexiconKeys);
     if (GUILayout.Button("Find") && lexiconKeys.IsNotEmpty())
     {
         Debug.Log(UIBuildScript.FindTextKey(lexiconKeys));
     }
     EditorGUILayout.EndHorizontal();
 }
示例#4
0
		public override void OnHeaderGUI(List<Object> found)
		{
			EditorGUIUtil.TextArea ("Exclude", ref exclude);
			EditorGUIUtil.Toggle("Exclude TexLoader", ref excludeTexLoader);
			EditorGUILayout.BeginHorizontal();
			EditorGUIUtil.TextField(null, ref filter);
			if (GUILayout.Button("Search")) {
				SetExclude(exclude);
				Search();
			}
			EditorGUILayout.EndHorizontal();
		}
 public override void OnHeaderGUI()
 {
     EditorGUIUtil.ObjectField <GameObject>("Scene Root", ref sceneRoot, true);
     GUI.enabled = sceneRoot != null;
     ComponentSelector.Draw <UIAtlas>("Select", NGUISettings.atlas, OnSelectAtlas, true);
     EditorGUIUtil.TextField("Filter", ref filter);
     if (EditorGUIUtil.Toggle("Expand", ref expand))
     {
         foreach (string s in spriteMap.Keys)
         {
             foldMap[s] = expand;
         }
     }
     GUI.enabled = true;
     NGUIEditorTools.DrawSeparator();
 }
示例#6
0
        private bool DrawTest()
        {
            showTest = EditorGUILayout.Foldout(showTest, "Test");
            bool changed = false;

            if (showTest)
            {
                EditorGUI.indentLevel += 2;
                EditorGUIUtil.ObjectField <UIFont>("Font", ref testFont, true);
                int row = grid.rowCount;
                int col = grid.columnCount;
                if (EditorGUIUtil.IntField("Font Size", ref fontSize, GUILayout.ExpandWidth(false)))
                {
                    for (int r = 0; r < row; r++)
                    {
                        for (int c = 0; c < col; c++)
                        {
                            UILabel label = grid.GetCell(r, c).GetComponent <UILabel>();
                            if (label != null)
                            {
                                label.transform.localScale = new Vector3(fontSize, fontSize, 1);
                            }
                        }
                    }
                }
                if (EditorGUIUtil.ColorField("Font Color", ref fontColor, GUILayout.ExpandWidth(false)))
                {
                    for (int r = grid.rowHeader; r < row; r++)
                    {
                        for (int c = grid.columnHeader; c < col; c++)
                        {
                            UILabel label = grid.GetCell(r, c).GetComponent <UILabel>();
                            if (label != null)
                            {
                                label.color = fontColor;
                                label.MarkAsChanged();
                            }
                        }
                    }
                }
                Array.Resize(ref testStrings, grid.maxPerLine);
                for (int i = 0; i < grid.maxPerLine; i++)
                {
                    EditorGUIUtil.TextField(i.ToString(), ref testStrings[i], GUILayout.ExpandWidth(false));
                }
                GUI.enabled = testFont != null;
                if (GUILayout.Button("Fill Data"))
                {
                    for (int r = grid.rowHeader; r < row; r++)
                    {
                        for (int c = grid.columnHeader; c < col; c++)
                        {
                            UITableCell cell = grid.GetCell(r, c);
                            if (cell == null)
                            {
                                UILabel label = NGUITools.AddWidget <UILabel>(grid.gameObject);
                                label.bitmapFont = testFont;
                                label.name       = "__TEST__";
                                label.SetText(testStrings[grid.isHorizontal?c:r]);
                                label.transform.localScale = new Vector3(fontSize, fontSize, 1);
                                label.color = fontColor;
                                label.MarkAsChanged();
                                UILabelCell lc = label.gameObject.AddComponent <UILabelCell>();
                                lc.label = label;
                                grid.SetCell(r, c, lc);
                            }
                        }
                    }
                    changed = true;
                }
                GUI.enabled            = true;
                EditorGUI.indentLevel -= 2;
            }
            return(changed);
        }
示例#7
0
        public override void OnInspectorGUI()
        {
            if (EditorUI.DrawHeader("Sprite -> Texture"))
            {
                EditorUI.BeginContents();
                EditorGUILayout.BeginHorizontal();
                EditorGUIUtil.ObjectField <Object>("Folder", ref texFolder, false);
                if (GUILayout.Button("Sprite -> Texture") && EditorUtility.DisplayDialog("Warning", "BackUp?", "OK", "Cancel"))
                {
                    ConvertToTexture(texFolder);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUIUtil.ObjectFieldReorderList(texList);
                EditorUI.EndContents();
            }
            if (EditorUI.DrawHeader("Texture -> Sprite"))
            {
                EditorUI.BeginContents();
                EditorGUILayout.BeginHorizontal();
                ComponentSelector.Draw <UIAtlas>("Atlas", atlasToAdd, OnSelectAtlas, true, GUILayout.MinWidth(80f));
                if (GUILayout.Button("Add Selected"))
                {
                    foreach (Object o in Selection.objects)
                    {
                        if (o is GameObject)
                        {
                            OnSelectAtlas((o as GameObject).GetComponent <UIAtlas>());
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
                EditorGUIUtil.TextField("Search sprite", ref searchSpriteName);
                if (searchSpriteName.IsNotEmpty())
                {
                    List <UIAtlas> filtered = new List <UIAtlas>();
                    foreach (UIAtlas a in atlasRefs)
                    {
                        if (a.GetSprite(searchSpriteName) != null)
                        {
                            filtered.Add(a);
                        }
                    }
                    EditorGUIUtil.ObjectFieldReorderList(filtered);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUIUtil.Popup("Change to", ref changeAtlas, filtered);
                    if (GUILayout.Button("Apply"))
                    {
                        BuildScript.ForEachPrefab((path, prefab) => {
                            ChangeAtlas(prefab, filtered, changeAtlas);
                            return(null);
                        });
                        BuildScript.ForEachScene(list => {
                            foreach (Transform t in list)
                            {
                                ChangeAtlas(t.gameObject, filtered, changeAtlas);
                            }
                            return(null);
                        });
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUIUtil.ObjectFieldReorderList(spriteList);
                }
                else
                {
                    if (EditorGUIUtil.ObjectFieldReorderList(atlasRefs))
                    {
                        SaveAtlasRefs();
                    }
                }
                if (dupSprites.IsNotEmpty())
                {
                    if (EditorUI.DrawHeader("Duplicate sprites"))
                    {
                        EditorUI.BeginContents();
                        float cellWidth = 200f;
                        float width     = GetWidth();
                        int   column    = Mathf.Max((int)(width / cellWidth), 1);
                        int   i         = 0;
                        foreach (string d in dupSprites)
                        {
                            if (i == 0)
                            {
                                EditorGUILayout.BeginHorizontal();
                            }
                            if (GUILayout.Button(d, GUILayout.Width(200)))
                            {
                                searchSpriteName = d;
                            }
                            i = i + 1;
                            if (i == column)
                            {
                                EditorGUILayout.EndHorizontal();
                                i = 0;
                            }
                        }
                        if (i != 0)
                        {
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorUI.EndContents();
                    }
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUIUtil.ObjectField("Target", ref targetObj, true);
                GUI.enabled = targetObj != null;
                if (GUILayout.Button("Convert to Sprite") && EditorUtility.DisplayDialog("Warning", "BackUp?", "OK"))
                {
                    ConvertToSprite();
                }
                if (GUILayout.Button("Set TexSetter"))
                {
                    foreach (UITexture tex in targetObj.GetComponentsInChildren <UITexture>(true))
                    {
                        TexSetterInspector.SetIfCdn(tex);
                    }
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
                // collect atlas
                GUI.enabled = targetObj != null;
                if (EditorUI.DrawHeader("Member Atlases"))
                {
                    EditorUI.BeginContents();
                    if (targetObj != null)
                    {
                        MultiMap <UIAtlas, UISprite> collect = new MultiMap <UIAtlas, UISprite>();
                        foreach (UISprite s in targetObj.GetComponentsInChildren <UISprite>(true))
                        {
                            collect.Add(s.atlas, s);
                        }
                        foreach (KeyValuePair <UIAtlas, List <UISprite> > pair in collect)
                        {
                            if (EditorGUILayout.Foldout(folding.Contains(pair.Key), pair.Key.name))
                            {
                                folding.Add(pair.Key);
                                EditorGUI.indentLevel++;
                                foreach (UISprite s in pair.Value)
                                {
                                    EditorGUILayout.ObjectField(s.gameObject, typeof(GameObject), true);
                                }
                                EditorGUI.indentLevel--;
                            }
                            else
                            {
                                folding.Remove(pair.Key);
                            }
                        }
                    }
                    EditorUI.EndContents();
                }
                if (EditorUI.DrawHeader("Orphan Texture"))
                {
                    EditorUI.BeginContents();
                    if (targetObj != null)
                    {
                        foreach (UITexture tex in targetObj.GetComponentsInChildren <UITexture>(true))
                        {
                            if (tex.GetComponent <TexLoader>() == null)
                            {
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.ObjectField(tex.gameObject, typeof(GameObject), true);
                                EditorGUILayout.ObjectField(tex.mainTexture, typeof(Texture), false);
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                    EditorUI.EndContents();
                }
                GUI.enabled = true;

                EditorUI.EndContents();
            }
            if (EditorUI.DrawHeader("Find All Sprites"))
            {
                EditorUI.BeginContents();
                EditorGUILayout.BeginHorizontal();
                ComponentSelector.Draw <UIAtlas>("Atlas", atlas4Sprite, OnSelectAtlasForSprite, true, GUILayout.MinWidth(80f));
                if (GUILayout.Button("Find"))
                {
                    var list = Resources.FindObjectsOfTypeAll <UISprite>().ToList(i => i as UISprite);
                    s4a.Clear();
                    foreach (var s in list)
                    {
                        if (s.atlas == atlas4Sprite)
                        {
                            s4a.Add(s);
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
                EditorUI.EndContents();
            }
            GUI.enabled = true;
        }