예제 #1
0
    public override void OnInspectorGUI()
    {
        richText4Chat = target as UIRichText4Chat;
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Face Atlas"))
        {
            ComponentSelector.Show <UIAtlas> (OnSelectAtlas);
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "faceAtlas", GUILayout.MinWidth(20f));

        if (atlas != null)
        {
            UIAtlas atl = atlas.objectReferenceValue as UIAtlas;
            if (atl != richText4Chat.faceAtlas)
            {
                Debug.Log(atl.name);
                richText4Chat.faceAtlas = atl;
                richText4Chat.atlasName = atl.name;
            }
        }

        if (GUILayout.Button("Edit", GUILayout.Width(40f)))
        {
            if (atlas != null)
            {
                UIAtlas atl = atlas.objectReferenceValue as UIAtlas;
                NGUISettings.atlas = atl;
                NGUIEditorTools.Select(atl.gameObject);
            }
        }
        GUILayout.EndHorizontal();

        DrawDefaultInspector();
    }
예제 #2
0
        public static void _resetAtlasAndFont(Transform tr, bool isClean)
        {
            UILabel lb = tr.GetComponent <UILabel> ();

            if (lb != null)
            {
                if (isClean)
                {
                    lb.bitmapFont = null;
                }
                else
                {
                    if (string.IsNullOrEmpty(lb.fontName))
                    {
                        lb.bitmapFont = CLUIInit.self.emptFont;
                    }
                    else
                    {
                        lb.bitmapFont = CLUIInit.self.getFontByName(lb.fontName);                         //font;
                    }
                }
            }

            HUDText hud = tr.GetComponent <HUDText> ();

            if (hud != null)
            {
                //			hud.font = font;
                if (isClean)
                {
                    hud.font = null;
                }
                else
                {
                    if (string.IsNullOrEmpty(hud.fontName))
                    {
                        hud.font = CLUIInit.self.emptFont;
                    }
                    else
                    {
                        hud.font = CLUIInit.self.getFontByName(hud.fontName);                         //font;
                    }
                }
            }

            UISprite sp = tr.GetComponent <UISprite> ();

            if (sp != null)
            {
                //			sp.atlas = atlas;
                if (isClean)
                {
                    sp.atlas = null;
                }
                else
                {
                    if (string.IsNullOrEmpty(sp.atlasName))
                    {
                        sp.atlas = CLUIInit.self.emptAtlas;
                    }
                    else
                    {
                        sp.atlas = CLUIInit.self.getAtlasByName(sp.atlasName);
                    }
                }
            }

            UIRichText4Chat rtc = tr.GetComponent <UIRichText4Chat> ();

            if (rtc != null)
            {
                if (isClean)
                {
                    rtc.faceAtlas = null;
                }
                else
                {
                    if (string.IsNullOrEmpty(rtc.atlasName))
                    {
                        rtc.faceAtlas = CLUIInit.self.emptAtlas;
                    }
                    else
                    {
                        rtc.faceAtlas = CLUIInit.self.getAtlasByName(rtc.atlasName);
                    }
                }
            }

            UIPopupList pop = tr.GetComponent <UIPopupList> ();

            if (pop != null)
            {
                //			pop.atlas = atlas;
                if (isClean)
                {
                    pop.atlas = null;
                }
                else
                {
                    if (string.IsNullOrEmpty(pop.atlasName))
                    {
                        pop.atlas = CLUIInit.self.emptAtlas;
                    }
                    else
                    {
                        pop.atlas = CLUIInit.self.getAtlasByName(pop.atlasName);
                    }
                }

                //			pop.bitmapFont = font;
                if (isClean)
                {
                    pop.bitmapFont = null;
                }
                else
                {
                    if (string.IsNullOrEmpty(pop.fontName))
                    {
                        pop.bitmapFont = CLUIInit.self.emptFont;
                    }
                    else
                    {
                        pop.bitmapFont = CLUIInit.self.getFontByName(pop.fontName);                         //font;
                    }
                }

                if (pop.bitmapFont == null)
                {
                    pop.trueTypeFont = null;
                }
            }

            for (int i = 0; i < tr.childCount; i++)
            {
                _resetAtlasAndFont(tr.GetChild(i), isClean);
            }
        }