protected void ShouldDrawProperties(MeshBuilder mb)
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Atlas", "DropDown", GUILayout.Width(76f)))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = serializedObject.FindProperty("mAtlas");

        EditorGUILayout.PropertyField(atlas, new GUIContent(""), GUILayout.MinWidth(20f));

        //mb.mAtlas = (UIAtlas)EditorGUILayout.ObjectField( "", mb.mAtlas, typeof(UIAtlas), true, GUILayout.MinWidth(20f) );
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Sprite", "DropDown", GUILayout.Width(76f)))
        {
            NGUISettings.atlas          = mb.mAtlas;
            NGUISettings.selectedSprite = mb.mSpriteName;
            SpriteSelector.Show(SelectSprite);
        }
        GUILayout.Label(mb.mSpriteName, "HelpBox", GUILayout.Height(18f));
        GUILayout.Space(18f);
        GUILayout.EndHorizontal();

        SerializedProperty sp = serializedObject.FindProperty("_Size");

        EditorGUILayout.PropertyField(sp);
    }
Exemple #2
0
    //绘制窗口时调用
    void OnGUI()
    {
        GUILayout.Space(20f);

        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }

        GUILayout.Label(UIATLAS_NAME, "HelpBox", GUILayout.Height(18f));
        //GUILayout.Label(atlasName, GUILayout.MinHeight(30f));
        GUILayout.EndHorizontal();

        GUILayout.Space(12f);
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("开始", GUILayout.MinHeight(20f), GUILayout.MaxWidth(100f)))
        {
            if (UIATLAS_NAME == "")
            {
                this.ShowNotification(new GUIContent("no select Atlas!"));
            }
            NGUIDepthManager.Show(selectTarget, UIATLAS_NAME);
            Close();
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(6f);
    }
    void DrawAtlas()
    {
        if (NGUIEditorTools.DrawHeader("Atlas"))
        {
            NGUIEditorTools.BeginContents();

            GUILayout.BeginHorizontal();
            {
                if (NGUIEditorTools.DrawPrefixButton("Atlas"))
                {
                    ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
                }
                NGUIEditorTools.DrawProperty("", serializedObject, "atlas");
            }
            GUILayout.EndHorizontal();

            NGUIEditorTools.DrawPaddedSpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground);
            NGUIEditorTools.DrawPaddedSpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight);

            EditorGUILayout.Space();

            NGUIEditorTools.DrawProperty("Background", serializedObject, "backgroundColor");
            NGUIEditorTools.DrawProperty("Highlight", serializedObject, "highlightColor");
            NGUIEditorTools.DrawProperty("Animated", serializedObject, "isAnimated");
            NGUIEditorTools.EndContents();
        }
    }
Exemple #4
0
    private void DrawReplaceToolBar()
    {
        GUI.backgroundColor = Color.white;
        GUI.Box(replaceAtalsRect, "");
        GUILayout.BeginArea(replaceAtalsRect);

        GUILayout.BeginHorizontal();
        originAtlas = (UIAtlas)EditorGUILayout.ObjectField("被替换图集", originAtlas, typeof(UIAtlas), true);
        if (NGUIEditorTools.DrawPrefixButton("选择Atlas", GUILayout.Width(200)))
        {
            isSelectOriginAtlas = true;
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        targetAtlas = (UIAtlas)EditorGUILayout.ObjectField("目标图集", targetAtlas, typeof(UIAtlas), true);
        if (NGUIEditorTools.DrawPrefixButton("选择Atlas", GUILayout.Width(200)))
        {
            isSelectTargetAtlas = true;
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Exemple #5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        NGraphUtils.DrawSeparator();

        UINgraph pGraph = (UINgraph)target;

        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Font"))
        {
            if (mType == UILabelInspector.FontType.NGUI)
            {
                ComponentSelector.Show <UIFont>(OnBitmapFont);
            }
            else
            {
                ComponentSelector.Show <Font>(OnDynamicFont);
            }
        }

#if DYNAMIC_FONT
        GUI.changed = false;

        if (mType == UILabelInspector.FontType.Unity)
        {
            Font fnt = (Font)EditorGUILayout.ObjectField(pGraph.AxisLabelDynamicFont, typeof(Font), false, GUILayout.Width(140f));
            if (fnt != pGraph.AxisLabelDynamicFont)
            {
                UndoableAction <UINgraph>(gr => gr.AxisLabelDynamicFont = fnt);
            }
        }
        else
        {
            UIFont fnt = (UIFont)EditorGUILayout.ObjectField(pGraph.AxisLabelBitmapFont, typeof(UIFont), false, GUILayout.Width(140f));
            if (fnt != pGraph.AxisLabelBitmapFont)
            {
                UndoableAction <UINgraph>(gr => gr.AxisLabelBitmapFont = fnt);
            }
        }
        mType = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(mType, GUILayout.Width(62f));
#else
        UIFont fnt = (UIFont)EditorGUILayout.ObjectField(pGraph.AxisLabelBitmapFont, typeof(UIFont), false, GUILayout.Width(140f));
        if (fnt != pGraph.AxisLabelBitmapFont)
        {
            UndoableAction <UINgraph>(gr => gr.AxisLabelBitmapFont = fnt);
        }
        mType = UILabelInspector.FontType.NGUI;
#endif

        GUILayout.Label("size", GUILayout.Width(30f));
        EditorGUI.BeginDisabledGroup(mType == UILabelInspector.FontType.NGUI);
        int i = EditorGUILayout.IntField(pGraph.fontSize, GUILayout.Width(30f));
        if (i != pGraph.fontSize)
        {
            UndoableAction <UINgraph>(gr => gr.fontSize = i);
        }
        EditorGUI.EndDisabledGroup();
        GUILayout.Label("font used by the labels");
        GUILayout.EndHorizontal();
    }
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        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();

        SerializedProperty sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UIAtlas, sp.stringValue, SelectSprite, false);
        return(true);
    }
Exemple #7
0
    public override void OnInspectorGUI()
    {
        effect = target as MeshEffect;

        EditorGUI.BeginChangeCheck();

        DrawDefaultInspector();

        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        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();

        SerializedProperty sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UIAtlas, sp.stringValue, SelectSprite, false);
    }
    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();
    }
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        var atlasProp = serializedObject.FindProperty("mAtlas");
        var obj       = atlasProp.objectReferenceValue;
        var atlas     = obj as INGUIAtlas;

        GUILayout.BeginHorizontal();

        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show(atlas, OnSelectAtlas);
        }

        atlasProp = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        if (GUILayout.Button("Edit", GUILayout.Width(40f)) && atlas != null)
        {
            NGUISettings.atlas = atlas;
            NGUIEditorTools.Select(atlas as Object);
        }

        // Legacy atlas support
        if (atlasProp.objectReferenceValue != null && atlasProp.objectReferenceValue is GameObject)
        {
            atlasProp.objectReferenceValue = (atlasProp.objectReferenceValue as GameObject).GetComponent <UIAtlas>();
        }

        GUILayout.EndHorizontal();
        var sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas, sp.stringValue, SelectSprite, false);
        NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");
        return(true);
    }
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected virtual bool ShouldDrawProperties()
    {
        GUILayout.BeginHorizontal();
        if (UGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UGUIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = UGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

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

        UGUISprite uguiSprite = target as UGUISprite;
        string     spriteName = uguiSprite.sprite == null ? "" : uguiSprite.sprite.name;

        UGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UGUIAtlas, spriteName, SelectSprite, true);
        return(true);
    }
Exemple #11
0
    /// <summary>
    /// Should we draw the widget's custom properties?
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <NGUIAtlas>(OnSelectAtlas);
        }

        var atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        if (GUILayout.Button("Edit", GUILayout.Width(40f)))
        {
            if (atlas != null)
            {
                var obj = atlas.objectReferenceValue;
                NGUISettings.atlas = obj as INGUIAtlas;
                if (obj != null)
                {
                    NGUIEditorTools.Select(obj);
                }
            }
        }

        GUILayout.EndHorizontal();

        NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");
        return(true);
    }
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

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

        SerializedProperty sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UIAtlas, sp.stringValue, SelectSprite, false);

        //change by zhehua
        //NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");
        if (atlas != null)
        {
            UIAtlas atl = atlas.objectReferenceValue as UIAtlas;
            if (atl != null)
            {
                if (atl.spriteMaterial != null)
                {
                    EditorGUILayout.LabelField("Sprite Material Name : " + atl.spriteMaterial.name, GUILayout.MinWidth(100f));
                }
                int effectMatDicCount = (atl.effectMatDic == null) ? 0 : atl.effectMatDic.Count;
                EditorGUILayout.LabelField("Effect Material Count : " + effectMatDicCount, GUILayout.MinWidth(100f));
                if (effectMatDicCount > 0)
                {
                    foreach (string key in atl.effectMatDic.Keys)
                    {
                        if (atl.effectMatDic[key] == null)
                        {
                            atl.DestroyAllEffectMaterials();
                            break;
                        }
                        EditorGUILayout.LabelField("        " + atl.effectMatDic[key].name, GUILayout.MinWidth(100f));
                    }
                }
            }
        }
        return(true);
    }
Exemple #13
0
 public void Show()
 {
     this.gameObject.SetActive(true);
     bodySelector.Show(fadeTime);
     foreach (ComponentSelector s in selectors)
     {
         s.Show(fadeTime);
     }
     back.DOFade(1f, fadeTime);
     createButton.image.DOFade(1f, fadeTime);
     isShow = true;
 }
Exemple #14
0
 public override void OnInspectorGUI()
 {
     serializedObject.Update();
     hud = target as HUDText;
     EditorGUILayout.BeginHorizontal(); {
         if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
         {
             ComponentSelector.Show <UIFont> (OnNGUIFont);
         }
         NGUIEditorTools.DrawProperty("Font Name", serializedObject, "fontName");                            // add by chenbin
     }
     EditorGUILayout.EndHorizontal();
     base.OnInspectorGUI();
 }
Exemple #15
0
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        var atlasProp = serializedObject.FindProperty("mAtlas");
        var obj       = atlasProp.objectReferenceValue;
        var atlas     = obj as INGUIAtlas;

        GUILayout.BeginHorizontal();

        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show(atlas, OnSelectAtlas);
        }

        atlasProp = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        if (GUILayout.Button("Edit", GUILayout.Width(40f)) && atlas != null)
        {
            NGUISettings.atlas = atlas;
            NGUIEditorTools.Select(atlas as Object);
        }

        // Legacy atlas support
        if (atlasProp.objectReferenceValue != null && atlasProp.objectReferenceValue is GameObject)
        {
            atlasProp.objectReferenceValue = (atlasProp.objectReferenceValue as GameObject).GetComponent <UIAtlas>();
        }

        GUILayout.EndHorizontal();
        var sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas, sp.stringValue, SelectSprite, false);
        NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");

        SerializedProperty fa = serializedObject.FindProperty("mFixedAspect");
        bool before           = fa.boolValue;

        NGUIEditorTools.DrawProperty("Fixed Aspect", fa);
        if (fa.boolValue != before)
        {
            (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f);
        }

        if (fa.boolValue)
        {
            EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info);
        }

        return(true);
    }
    void DrawArrowSprites()
    {
        NGUIEditorTools.SetLabelWidth(80f);

        if (NGUIEditorTools.DrawHeader("Arrow Layout"))
        {
            NGUIEditorTools.BeginContents();

            NGUIEditorTools.DrawProperty("Arrow Sprite", serializedObject, "arrowElement");

            if (mList.arrowElement != null)
            {
                EditorGUILayout.Space();

                SerializedObject obj = new SerializedObject(mList.arrowElement);
                obj.Update();

                GUILayout.BeginHorizontal();

                if (NGUIEditorTools.DrawPrefixButton("Atlas"))
                {
                    ComponentSelector.Show <UIAtlas>(OnSelectArrowAtlas);
                }

                SerializedProperty atlas = NGUIEditorTools.DrawProperty("", obj, "mAtlas", GUILayout.MinWidth(20f));

                GUILayout.EndHorizontal();

                if (mList.arrowElement.atlas != null)
                {
                    EditorGUILayout.Space();

                    NGUIEditorTools.DrawSpriteField("Closed", obj, atlas, obj.FindProperty("mSpriteName"), true);
                    NGUIEditorTools.DrawSpriteField("Closed Hover", serializedObject, atlas, serializedObject.FindProperty("arrowClosedHoverSprite"), true);

                    EditorGUILayout.Space();

                    NGUIEditorTools.DrawSpriteField("Opened", serializedObject, atlas, serializedObject.FindProperty("arrowOpenedSprite"), true);
                    NGUIEditorTools.DrawSpriteField("Opened Hover", serializedObject, atlas, serializedObject.FindProperty("arrowOpenedHoverSprite"), true);
                }

                obj.ApplyModifiedProperties();
            }

            NGUIEditorTools.EndContents();
        }
    }
    void DrawAtlas()
    {
        if (NGUIEditorTools.DrawHeader("Atlas"))
        {
            NGUIEditorTools.BeginContents();

            SerializedProperty atlasSp = null;

            GUILayout.BeginHorizontal();
            {
                if (NGUIEditorTools.DrawPrefixButton("Atlas"))
                {
                    if (mList.atlas is UIAtlas)
                    {
                        ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
                    }
                    else
                    {
                        ComponentSelector.Show <NGUIAtlas>(OnSelectAtlas);
                    }
                }
                atlasSp = NGUIEditorTools.DrawProperty("", serializedObject, "atlas");
            }
            GUILayout.EndHorizontal();

            if (atlasSp != null && atlasSp.objectReferenceValue != null)
            {
                NGUIEditorTools.DrawPaddedSpriteField("Background", mList.atlas as INGUIAtlas, mList.backgroundSprite, OnBackground);
                NGUIEditorTools.DrawPaddedSpriteField("Highlight", mList.atlas as INGUIAtlas, mList.highlightSprite, OnHighlight);
            }
            else
            {
                serializedObject.DrawProperty("background2DSprite", "Background");
                serializedObject.DrawProperty("highlight2DSprite", "Highlight");
            }

            EditorGUILayout.Space();

            NGUIEditorTools.DrawProperty("Background", serializedObject, "backgroundColor");
            NGUIEditorTools.DrawProperty("Highlight", serializedObject, "highlightColor");
            NGUIEditorTools.DrawProperty("Overlap", serializedObject, "overlap", GUILayout.Width(110f));
            NGUIEditorTools.DrawProperty("Animated", serializedObject, "isAnimated");
            NGUIEditorTools.EndContents();
        }
    }
        void DrawAtlas()
        {
            EditorGUILayout.Space();
            ProjectorLight l = target as ProjectorLight;

            GUILayout.Label("Sprite");
            GUILayout.BeginVertical("box");
            GUILayout.BeginHorizontal();
            if (IFPipelineEditorTools.DrawPrefixButton("Atlas"))
            {
                ComponentSelector.Show <SpritesAtlas>(OnSelectAtlas);
            }
            SerializedProperty atlas = IFPipelineEditorTools.DrawProperty("", serializedObject, "spritesAtlas", GUILayout.MinWidth(20f));

            GUILayout.EndHorizontal();

            if (atlas != null)
            {
                SpritesAtlas atl = atlas.objectReferenceValue as SpritesAtlas;
                if (atl != null && atl != l.spritesAtlas)
                {
                    l.spritesAtlas = atl;
                }
                GUILayout.Label("Project Sprite");
                GUILayout.BeginHorizontal();
                SerializedProperty sp = serializedObject.FindProperty("mprojSpriteName");
                IFPipelineEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as SpritesAtlas, sp.stringValue, SelectProjSprite, false);
                GUILayout.EndHorizontal();
                GUILayout.Label("Falloff Sprite");
                GUILayout.BeginHorizontal();
                SerializedProperty spfalloff = serializedObject.FindProperty("mfalloffSpriteName");
                IFPipelineEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as SpritesAtlas, spfalloff.stringValue, SelectFalloffSprite, false);
                GUILayout.EndHorizontal();
            }
            else
            {
                l.mprojSpriteName    = "";
                l.mfalloffSpriteName = "";
                l.falloffSpriteData  = new SpriteData();
                l.projSpriteData     = new SpriteData();
                Tools.SetDirty(serializedObject.targetObject);
            }
            GUILayout.EndVertical();
        }
    void DrawSelectField()
    {
        NGUIEditorTools.SetLabelWidth(100f);

        if (NGUIEditorTools.DrawHeader("Select Field Layout"))
        {
            NGUIEditorTools.BeginContents();

            NGUIEditorTools.DrawProperty("Background Sprite", serializedObject, "backgroundElement");

            if (mList.backgroundElement != null)
            {
                EditorGUILayout.Space();

                SerializedObject obj = new SerializedObject(mList.backgroundElement);
                obj.Update();

                GUILayout.BeginHorizontal();

                if (NGUIEditorTools.DrawPrefixButton("Atlas"))
                {
                    ComponentSelector.Show <UIAtlas>(OnSelectBackgroundAtlas);
                }

                SerializedProperty atlas = NGUIEditorTools.DrawProperty("", obj, "mAtlas", GUILayout.MinWidth(20f));

                GUILayout.EndHorizontal();

                EditorGUILayout.Space();

                NGUIEditorTools.DrawSpriteField("Sprite Normal", obj, atlas, obj.FindProperty("mSpriteName"));
                NGUIEditorTools.DrawSpriteField("Sprite Focused", serializedObject, atlas, serializedObject.FindProperty("fieldFocusedSprite"), true);

                EditorGUILayout.Space();

                NGUIEditorTools.DrawProperty("Color Normal", obj, "mColor");
                NGUIEditorTools.DrawProperty("Color Focused", serializedObject, "fieldFocusedColor");

                obj.ApplyModifiedProperties();
            }

            NGUIEditorTools.EndContents();
        }
    }
Exemple #20
0
    public override void OnInspectorGUI()
    {
        UGUISprite _sprite = target as UGUISprite;

        //选择图集
        if (GUILayout.Button("选择图集", "DropDown", GUILayout.Width(76f)))
        {
            ComponentSelector.Show <UGUIAtlas>((_obj) =>
            {
                _sprite.Atlas = _obj as UGUIAtlas;
            });
        }
        _sprite.Atlas = EditorGUILayout.ObjectField("图集", _sprite.Atlas, typeof(UGUIAtlas), true) as UGUIAtlas;
        if (_sprite.Atlas != null)      //有图集的情况下,根据name获取图片
        {
            ////选择图集中的图片
            //if (GUILayout.Button("选择图集", "DropDown", GUILayout.Width(76f)))
            //{
            //    SpriteSelector.Show(_sprite.Atlas, (_obj) =>
            //    {
            //        _sprite.sprite = _obj;
            //    });
            //    Debug.Log("选中了一张图片");
            //}

            if (_sprite.sprite != null)
            {
                if (_sprite.Name != _sprite.sprite.name)
                {
                    _sprite.Name = _sprite.sprite.name;
                }
            }
            else
            {
                if (_sprite.Name != "")
                {
                    _sprite.InitSprite();
                }
            }
        }
        EditorGUILayout.LabelField("图片名称:" + _sprite.Name);

        base.OnInspectorGUI();
    }
Exemple #21
0
    protected bool ShouldDrawProperties()
    {
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <AtlasSheet>(OnSelectAtlas);
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        if (GUILayout.Button("Rand", GUILayout.Width(40f)))
        {
            if (atlas != null && Selection.objects.Length > 0)
            {
                AtlasSheet atl = atlas.objectReferenceValue as AtlasSheet;

                foreach (var sprite_obj in Selection.gameObjects)
                {
                    AtlasSprite sprite = sprite_obj.GetComponent <AtlasSprite>();
                    sprite.spriteName = atl.Atlas.spriteList[UnityEngine.Random.Range(0, atl.Atlas.spriteList.Count - 1)].name;
                }
            }
        }

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

        SerializedProperty sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField((atlas.objectReferenceValue as AtlasSheet).Atlas, sp.stringValue, SelectSprite, false);

        return(true);
    }
Exemple #22
0
    void DrawSelectField()
    {
        if (NGUIEditorTools.DrawHeader("Select Field Layout"))
        {
            NGUIEditorTools.BeginContents();

            GUILayout.BeginHorizontal();
            {
                if (NGUIEditorTools.DrawPrefixButton("Atlas"))
                {
                    ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
                }

                NGUIEditorTools.DrawProperty("", serializedObject, "atlas");
            }
            GUILayout.EndHorizontal();

            NGUIEditorTools.DrawPaddedSpriteField("Field Normal", mList.atlas, mList.fieldNormalSprite, OnFieldNormal);
            NGUIEditorTools.DrawPaddedSpriteField("Field Focused", mList.atlas, mList.fieldFocusedSprite, OnFieldFocused);

            EditorGUILayout.Space();

            NGUIEditorTools.DrawProperty("Field Normal", serializedObject, "fieldNormalColor");
            NGUIEditorTools.DrawProperty("Field Focused", serializedObject, "fieldFocusedColor");

            EditorGUILayout.Space();

            NGUIEditorTools.DrawProperty("Label Normal", serializedObject, "labelNormalColor");
            NGUIEditorTools.DrawProperty("Label Focused", serializedObject, "labelFocusedColor");

            EditorGUILayout.Space();

            NGUIEditorTools.DrawPaddedSpriteField("Arrow Closed", mList.atlas, mList.arrowClosedSprite, OnArrowClosed);
            NGUIEditorTools.DrawPaddedSpriteField("Arrow Hover Closed", mList.atlas, mList.arrowClosedHoverSprite, OnArrowHoverClosed);
            NGUIEditorTools.DrawPaddedSpriteField("Arrow Opened", mList.atlas, mList.arrowOpenedSprite, OnArrowOpened);
            NGUIEditorTools.DrawPaddedSpriteField("Arrow Hover Opened", mList.atlas, mList.arrowOpenedHoverSprite, OnArrowHoverOpened);

            NGUIEditorTools.EndContents();
        }
    }
Exemple #23
0
    protected override bool ShouldDrawProperties()
    {
        if (target == null)
        {
            return(false);
        }

        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }


        EditorGUILayout.ObjectField(mTex.mAtlas, typeof(UIAtlas), GUILayout.Width(100));
        GUILayout.EndHorizontal();

        SerializedProperty isSharedMaterial = NGUIEditorTools.DrawProperty("isSharedMaterial", serializedObject, "isSharedMaterial", GUILayout.MinWidth(20f));

        base.ShouldDrawProperties();
        return(true);
    }
    // copy from UISpriteInspector
    void ShowParticleSprite()
    {
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(obj => {
                serializedObject.Update();
                SerializedProperty spNew   = serializedObject.FindProperty("Atlas");
                spNew.objectReferenceValue = obj;
                serializedObject.ApplyModifiedProperties();
                NGUITools.SetDirty(serializedObject.targetObject);
                NGUISettings.atlas = obj as UIAtlas;
            });
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "Atlas", GUILayout.MinWidth(20f));

        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();

        SerializedProperty sp = serializedObject.FindProperty("SpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UIAtlas, sp.stringValue, spriteName => {
            serializedObject.Update();
            SerializedProperty spNew = serializedObject.FindProperty("SpriteName");
            spNew.stringValue        = spriteName;
            serializedObject.ApplyModifiedProperties();
            NGUITools.SetDirty(serializedObject.targetObject);
            NGUISettings.selectedSprite = spriteName;
        }, false);
    }
Exemple #25
0
    // Start is called before the first frame update
    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(80f);
        EditorGUILayout.Space();

        serializedObject.Update();
        //Atlas
        GUILayout.BeginHorizontal();
        if (NGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        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();

        SerializedProperty sp = serializedObject.FindProperty("mSpriteName");

        NGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UIAtlas, sp.stringValue, SelectSprite, false);

        if (GUILayout.Button("Refresh"))
        {
            var it = target as ParticleSystemExt;
            it.RefreshParticleSystem();
        }

        serializedObject.ApplyModifiedProperties();
    }
    void DrawFont()
    {
        if (NGUIEditorTools.DrawHeader("Font"))
        {
            NGUIEditorTools.BeginContents();

            SerializedProperty ttf = null;

            GUILayout.BeginHorizontal();
            {
                if (NGUIEditorTools.DrawPrefixButton("Font"))
                {
                    if (mType == FontType.Bitmap)
                    {
                        ComponentSelector.Show <UIFont>(OnBitmapFont);
                    }
                    else
                    {
                        ComponentSelector.Show <Font>(OnDynamicFont, new string[] { ".ttf", ".otf" });
                    }
                }

#if DYNAMIC_FONT
                GUI.changed = false;
                mType       = (FontType)EditorGUILayout.EnumPopup(mType, GUILayout.Width(62f));

                if (GUI.changed)
                {
                    GUI.changed = false;

                    if (mType == FontType.Bitmap)
                    {
                        serializedObject.FindProperty("trueTypeFont").objectReferenceValue = null;
                    }
                    else
                    {
                        serializedObject.FindProperty("bitmapFont").objectReferenceValue = null;
                    }
                }
#else
                mType = FontType.Bitmap;
#endif

                if (mType == FontType.Bitmap)
                {
                    NGUIEditorTools.DrawProperty("", serializedObject, "bitmapFont", GUILayout.MinWidth(40f));
                }
                else
                {
                    ttf = NGUIEditorTools.DrawProperty("", serializedObject, "trueTypeFont", GUILayout.MinWidth(40f));
                }
            }
            GUILayout.EndHorizontal();

            if (ttf != null && ttf.objectReferenceValue != null)
            {
                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup(ttf.hasMultipleDifferentValues);
                    NGUIEditorTools.DrawProperty("Font Size", serializedObject, "fontSize", GUILayout.Width(142f));
                    NGUIEditorTools.DrawProperty("", serializedObject, "fontStyle", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawPadding();
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                NGUIEditorTools.DrawProperty("Font Size", serializedObject, "fontSize", GUILayout.Width(142f));
            }

            NGUIEditorTools.DrawProperty("Text Color", serializedObject, "textColor");

            GUILayout.BeginHorizontal();
            NGUIEditorTools.SetLabelWidth(66f);
            EditorGUILayout.PrefixLabel("Padding");
            NGUIEditorTools.SetLabelWidth(14f);
            NGUIEditorTools.DrawProperty("X", serializedObject, "padding.x", GUILayout.MinWidth(30f));
            NGUIEditorTools.DrawProperty("Y", serializedObject, "padding.y", GUILayout.MinWidth(30f));
            NGUIEditorTools.DrawPadding();
            NGUIEditorTools.SetLabelWidth(80f);
            GUILayout.EndHorizontal();

            NGUIEditorTools.EndContents();
        }
    }
Exemple #27
0
    /// <summary>
    /// Draw the label's properties.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        mIsDynamic  = false;
        mHasSymbols = false;
        mLabel      = mWidget as UILabel;

        GUILayout.BeginHorizontal();

#if DYNAMIC_FONT
        mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f));
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
#else
        mFontType = FontType.NGUI;
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f)))
#endif
        {
            if (mFontType == FontType.NGUI)
            {
                var bmf = mLabel.font;
                if (bmf != null && bmf is UIFont)
                {
                    ComponentSelector.Show <UIFont>(OnNGUIFont);
                }
                else
                {
                    ComponentSelector.Show <NGUIFont>(OnNGUIFont);
                }
            }
            else
            {
                ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
            }
        }

        bool isValid           = false;
        SerializedProperty fnt = null;
        SerializedProperty ttf = null;
        GUI.changed = false;

        if (mFontType == FontType.NGUI)
        {
            fnt = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f));

            // Legacy font support
            if (fnt.objectReferenceValue != null && fnt.objectReferenceValue is GameObject)
            {
                fnt.objectReferenceValue = (fnt.objectReferenceValue as GameObject).GetComponent <UIFont>();
            }

            if (fnt.objectReferenceValue != null)
            {
                if (GUI.changed)
                {
                    serializedObject.FindProperty("mTrueTypeFont").objectReferenceValue = null;
                }
                NGUISettings.ambigiousFont = fnt.objectReferenceValue;
                isValid = true;
            }
        }
        else
        {
            ttf = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f));

            if (ttf.objectReferenceValue != null)
            {
                if (GUI.changed)
                {
                    serializedObject.FindProperty("mFont").objectReferenceValue = null;
                }
                NGUISettings.ambigiousFont = ttf.objectReferenceValue;
                isValid = true;
            }
        }

        GUILayout.EndHorizontal();

#if UNITY_5_6
        if (mFontType == FontType.Unity)
        {
            EditorGUILayout.HelpBox("Dynamic fonts suffer from issues in Unity itself where your characters may disappear, get garbled, or just not show at times. Use this feature at your own risk.\n\n" +
                                    "When you do run into such issues, please submit a Bug Report to Unity via Help -> Report a Bug (as this is will be a Unity bug, not an NGUI one).", MessageType.Warning);
        }
#endif

        NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");

        EditorGUI.BeginDisabledGroup(!isValid);
        {
            var dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null;
            var bmFont  = (fnt != null) ? fnt.objectReferenceValue : null;
            var bm      = bmFont as INGUIFont;

            if (bm != null && bm.isDynamic)
            {
                dynFont     = bm.dynamicFont;
                mHasSymbols = bm.hasSymbols;
                bm          = null;
            }

            if (dynFont != null)
            {
                mIsDynamic = true;

                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues);

                    var prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));
                    NGUISettings.fontSize = prop.intValue;

                    prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f));
                    NGUISettings.fontStyle = (FontStyle)prop.intValue;

                    if (!serializedObject.isEditingMultipleObjects)
                    {
                        var printed = mLabel.finalFontSize;

                        if (mLabel.overflowMethod == UILabel.Overflow.ShrinkContent && printed != mLabel.fontSize)
                        {
                            EditorGUI.BeginDisabledGroup(true);
                            GUILayout.Label(" Printed: " + printed);
                            EditorGUI.EndDisabledGroup();
                        }
                        else
                        {
                            NGUIEditorTools.DrawPadding();
                        }
                    }
                    else
                    {
                        NGUIEditorTools.DrawPadding();
                    }

                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
            }
            else if (bmFont != null)
            {
                GUILayout.BeginHorizontal();
                var prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));

                EditorGUI.BeginDisabledGroup(true);

                if (!serializedObject.isEditingMultipleObjects)
                {
                    var printed = mLabel.finalFontSize;
                    var def     = mLabel.defaultFontSize;

                    if (mLabel.overflowMethod == UILabel.Overflow.ShrinkContent && printed != mLabel.fontSize)
                    {
                        GUILayout.Label(" Printed: " + printed);
                    }
                    else if (printed != def)
                    {
                        GUILayout.Label(" Default: " + def);
                    }
                }

                EditorGUI.EndDisabledGroup();

                NGUISettings.fontSize = prop.intValue;
                GUILayout.EndHorizontal();
            }

            bool ww = GUI.skin.textField.wordWrap;
            GUI.skin.textField.wordWrap = true;
            SerializedProperty sp = serializedObject.FindProperty("mText");

            if (sp.hasMultipleDifferentValues)
            {
                NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f));
            }
            else
            {
                GUIStyle style = new GUIStyle(EditorStyles.textField);
                style.wordWrap = true;

                float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f);
                bool  offset = true;

                if (height > 90f)
                {
                    offset = false;
                    height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(76f));
                    GUILayout.Space(3f);
                    GUILayout.Label("Text");
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                }
                Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height));

                GUI.changed = false;
                string text = EditorGUI.TextArea(rect, sp.stringValue, style);
                if (GUI.changed)
                {
                    sp.stringValue = text;
                }

                if (offset)
                {
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }

            GUI.skin.textField.wordWrap = ww;

            NGUIEditorTools.DrawPaddedProperty("Modifier", serializedObject, "mModifier");

            SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow");
            NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue;
            if (NGUISettings.overflowStyle == UILabel.Overflow.ClampContent)
            {
                NGUIEditorTools.DrawProperty("Use Ellipsis", serializedObject, "mOverflowEllipsis", GUILayout.Width(110f));
            }

            if (NGUISettings.overflowStyle == UILabel.Overflow.ResizeFreely)
            {
                GUILayout.BeginHorizontal();
                SerializedProperty s = NGUIEditorTools.DrawPaddedProperty("Max Width", serializedObject, "mOverflowWidth");

                if (s != null)
                {
                    if (s.intValue < 0)
                    {
                        s.intValue = 0;
                    }
                    if (s.intValue == 0)
                    {
                        GUILayout.Label("unlimited");
                    }
                }

                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                s = NGUIEditorTools.DrawPaddedProperty("Max Height", serializedObject, "mOverflowHeight");

                if (s != null)
                {
                    if (s.intValue < 0)
                    {
                        s.intValue = 0;
                    }
                    if (s.intValue == 0)
                    {
                        GUILayout.Label("unlimited");
                    }
                }

                GUILayout.EndHorizontal();
            }

            NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment");

            if (dynFont != null)
            {
                NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk");
            }

            if (bm != null)
            {
                EditorGUI.BeginDisabledGroup(bm.packedFontShader);
            }
            else
            {
                EditorGUI.BeginDisabledGroup(false);
            }

            GUILayout.BeginHorizontal();
            SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient",
                                                                 GUILayout.Width(95f));

            EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
            {
                NGUIEditorTools.SetLabelWidth(30f);
                NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                NGUIEditorTools.SetLabelWidth(50f);
                GUILayout.Space(79f);

                NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f));
                NGUIEditorTools.SetLabelWidth(80f);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Effect", GUILayout.Width(76f));
            sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f));

            EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue);
            {
                NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(" ", GUILayout.Width(56f));
                    NGUIEditorTools.SetLabelWidth(20f);
                    NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawPadding();
                    NGUIEditorTools.SetLabelWidth(80f);
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            sp = NGUIEditorTools.DrawProperty("Float spacing", serializedObject, "mUseFloatSpacing", GUILayout.Width(100f));

            if (!sp.boolValue)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mFloatSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mFloatSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }

            NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f));

            GUILayout.BeginHorizontal();
            sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f));

            EditorGUI.BeginDisabledGroup(!mHasSymbols || !sp.boolValue);
            NGUIEditorTools.SetLabelWidth(60f);
            NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols");
            NGUIEditorTools.SetLabelWidth(80f);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
        EditorGUI.EndDisabledGroup();
        return(isValid);
    }
Exemple #28
0
    /// <summary>
    /// Draw the label's properties.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        mLabel = mWidget as UILabel;

        GUILayout.BeginHorizontal();

#if DYNAMIC_FONT
        mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f));
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
#else
        mFontType = FontType.NGUI;
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f)))
#endif
        {
            if (mFontType == FontType.NGUI)
            {
                ComponentSelector.Show <UIFont>(OnNGUIFont);
            }
            else
            {
                ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
            }
        }

        bool isValid           = false;
        SerializedProperty fnt = null;
        SerializedProperty ttf = null;

        if (mFontType == FontType.NGUI)
        {
            fnt = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f));

            if (fnt.objectReferenceValue != null)
            {
                NGUISettings.ambigiousFont = fnt.objectReferenceValue;
                isValid = true;
            }
        }
        else
        {
            ttf = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f));

            if (ttf.objectReferenceValue != null)
            {
                NGUISettings.ambigiousFont = ttf.objectReferenceValue;
                isValid = true;
            }
        }

        GUILayout.EndHorizontal();

        EditorGUI.BeginDisabledGroup(!isValid);
        {
            UIFont uiFont  = (fnt != null) ? fnt.objectReferenceValue as UIFont : null;
            Font   dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null;

            if (uiFont != null && uiFont.isDynamic)
            {
                dynFont = uiFont.dynamicFont;
                uiFont  = null;
            }

            if (dynFont != null)
            {
                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues);

                    SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));
                    NGUISettings.fontSize = prop.intValue;

                    prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f));
                    NGUISettings.fontStyle = (FontStyle)prop.intValue;

                    NGUIEditorTools.DrawPadding();
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();

                NGUIEditorTools.DrawProperty("Material", serializedObject, "mMaterial");
            }
            else if (uiFont != null)
            {
                GUILayout.BeginHorizontal();
                SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));

                EditorGUI.BeginDisabledGroup(true);
                if (!serializedObject.isEditingMultipleObjects)
                {
                    GUILayout.Label(" Default: " + mLabel.defaultFontSize);
                }
                EditorGUI.EndDisabledGroup();

                NGUISettings.fontSize = prop.intValue;
                GUILayout.EndHorizontal();
            }

            bool ww = GUI.skin.textField.wordWrap;
            GUI.skin.textField.wordWrap = true;
            SerializedProperty sp = serializedObject.FindProperty("mText");

            if (sp.hasMultipleDifferentValues)
            {
                NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f));
            }
            else
            {
                GUIStyle style = new GUIStyle(EditorStyles.textField);
                style.wordWrap = true;

                float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f);
                bool  offset = true;

                if (height > 90f)
                {
                    offset = false;
                    height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(76f));
                    GUILayout.Space(3f);
                    GUILayout.Label("Text");
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                }
                Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height));

                GUI.changed = false;
                string text = EditorGUI.TextArea(rect, sp.stringValue, style);
                if (GUI.changed)
                {
                    sp.stringValue = text;
                }

                if (offset)
                {
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }

            GUI.skin.textField.wordWrap = ww;

            SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow");
            NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue;

            SerializedProperty ovNumberShowType = NGUIEditorTools.DrawPaddedProperty("NumShowType", serializedObject, "mNumShowType");
            NGUISettings.numShowTypeStyle = (UILabel.NumShowType)ovNumberShowType.intValue;

            NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment");

            if (dynFont != null)
            {
                NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk");
            }

            EditorGUI.BeginDisabledGroup(mLabel.bitmapFont != null && mLabel.bitmapFont.packedFontShader);
            GUILayout.BeginHorizontal();
            SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient",
                                                                 GUILayout.Width(95f));

            EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
            {
                NGUIEditorTools.SetLabelWidth(30f);
                NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                NGUIEditorTools.SetLabelWidth(50f);
                GUILayout.Space(79f);

                NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f));
                NGUIEditorTools.SetLabelWidth(80f);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Effect", GUILayout.Width(76f));
            sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f));

            EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue);
            {
                NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(" ", GUILayout.Width(56f));
                    NGUIEditorTools.SetLabelWidth(20f);
                    NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawPadding();
                    NGUIEditorTools.SetLabelWidth(80f);
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Spacing", GUILayout.Width(56f));
            NGUIEditorTools.SetLabelWidth(20f);
            NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f));
            NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f));
            NGUIEditorTools.DrawPadding();
            NGUIEditorTools.SetLabelWidth(80f);
            GUILayout.EndHorizontal();

            NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f));

            GUILayout.BeginHorizontal();
            sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f));
            EditorGUI.BeginDisabledGroup(!sp.boolValue || mLabel.bitmapFont == null || !mLabel.bitmapFont.hasSymbols);
            NGUIEditorTools.SetLabelWidth(60f);
            NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols");
            NGUIEditorTools.SetLabelWidth(80f);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
        EditorGUI.EndDisabledGroup();
        return(isValid);
    }
Exemple #29
0
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        // Load the saved preferences
        if (!mLoaded)
        {
            mLoaded = true;
            Load();
#if DYNAMIC_FONT
            Object font = NGUISettings.ambigiousFont;
            mType = ((font != null) && (font is UIFont)) ? UILabelInspector.FontType.NGUI : UILabelInspector.FontType.Unity;
#else
            mType = UILabelInspector.FontType.NGUI;
#endif
        }

        NGUIEditorTools.SetLabelWidth(80f);
        GameObject go = NGUIEditorTools.SelectedRoot();

        if (go == null)
        {
            GUILayout.Label("You must create a UI first.");

            if (GUILayout.Button("Open the New UI Wizard"))
            {
                EditorWindow.GetWindow <UICreateNewUIWizard>(false, "New UI", true);
            }
        }
        else
        {
            GUILayout.Space(4f);

            GUILayout.BeginHorizontal();
            ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas, false, GUILayout.Width(140f));
            GUILayout.Label("Texture atlas used by widgets", GUILayout.Width(10000f));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (NGUIEditorTools.DrawPrefixButton("Font"))
            {
                if (mType == UILabelInspector.FontType.NGUI)
                {
                    ComponentSelector.Show <UIFont>(OnFont);
                }
                else
                {
                    ComponentSelector.Show <Font>(OnFont, new string[] { ".ttf", ".otf" });
                }
            }

#if DYNAMIC_FONT
            GUI.changed = false;

            if (mType == UILabelInspector.FontType.Unity)
            {
                NGUISettings.ambigiousFont = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont, typeof(Font), false, GUILayout.Width(140f));
            }
            else
            {
                NGUISettings.ambigiousFont = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont, typeof(UIFont), false, GUILayout.Width(140f));
            }
            mType = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(mType, GUILayout.Width(62f));
#else
            NGUISettings.ambigiousFont = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont, typeof(UIFont), false, GUILayout.Width(140f));
#endif
            GUILayout.Label("size", GUILayout.Width(30f));
            EditorGUI.BeginDisabledGroup(mType == UILabelInspector.FontType.NGUI);
            NGUISettings.fontSize = EditorGUILayout.IntField(NGUISettings.fontSize, GUILayout.Width(30f));
            EditorGUI.EndDisabledGroup();
            GUILayout.Label("font used by the labels");
            GUILayout.EndHorizontal();
            NGUIEditorTools.DrawSeparator();

            GUILayout.BeginHorizontal();
            WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mWidgetType, GUILayout.Width(200f));
            GUILayout.Space(20f);
            GUILayout.Label("Select a widget template to use");
            GUILayout.EndHorizontal();

            if (mWidgetType != wt)
            {
                mWidgetType = wt; Save();
            }

            switch (mWidgetType)
            {
            case WidgetType.Label:                  CreateLabel(go); break;

            case WidgetType.Sprite:                 CreateSprite(go); break;

            case WidgetType.Texture:                CreateSimpleTexture(go); break;

            case WidgetType.Button:                 CreateButton(go); break;

            case WidgetType.ImageButton:    CreateImageButton(go); break;

            case WidgetType.Toggle:                 CreateToggle(go); break;

            case WidgetType.ProgressBar:    CreateSlider(go, false); break;

            case WidgetType.Slider:                 CreateSlider(go, true); break;

            case WidgetType.Input:                  CreateInput(go); break;

            case WidgetType.PopupList:              CreatePopup(go, true); break;

            case WidgetType.PopupMenu:              CreatePopup(go, false); break;

            case WidgetType.ScrollBar:              CreateScrollBar(go); break;
            }

            EditorGUILayout.HelpBox("Widget Tool has become far less useful with NGUI 3.0.6. Search the Project view for 'Control', then simply drag & drop one of them into your Scene View.", MessageType.Warning);
        }
    }
Exemple #30
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.labelWidth = 100f;
        mRealm = target as RnMUI_RealmSelect_Realm;

        serializedObject.Update();

        EditorGUILayout.Space();
        NGUIEditorTools.DrawProperty("Target", serializedObject, "target");
        EditorGUILayout.Space();

        NGUIEditorTools.DrawProperty("Is Closed", serializedObject, "isClosed");
        NGUIEditorTools.DrawProperty("Status", serializedObject, "currentStatus");
        NGUIEditorTools.DrawProperty("Population", serializedObject, "currentPop");
        EditorGUILayout.Space();

        if (mRealm.target != null)
        {
            if (NGUIEditorTools.DrawHeader("Sprites"))
            {
                NGUIEditorTools.BeginContents();
                EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
                {
                    SerializedObject obj = new SerializedObject(mRealm.target);
                    obj.Update();

                    GUILayout.BeginHorizontal();

                    if (NGUIEditorTools.DrawPrefixButton("Atlas"))
                    {
                        ComponentSelector.Show <UIAtlas>(OnSelectBackgroundAtlas);
                    }

                    SerializedProperty atlas = NGUIEditorTools.DrawProperty("", obj, "mAtlas", GUILayout.MinWidth(20f));

                    GUILayout.EndHorizontal();
                    EditorGUILayout.Space();

                    NGUIEditorTools.DrawSpriteField("Normal", obj, atlas, obj.FindProperty("mSpriteName"));

                    obj.ApplyModifiedProperties();

                    NGUIEditorTools.DrawSpriteField("Hovered", serializedObject, atlas, serializedObject.FindProperty("hoverSprite"), true);
                    NGUIEditorTools.DrawSpriteField("Active", serializedObject, atlas, serializedObject.FindProperty("activeSprite"), true);
                }
                EditorGUI.EndDisabledGroup();
                NGUIEditorTools.EndContents();
            }
        }

        EditorGUILayout.Space();
        NGUIEditorTools.DrawProperty("Chars Label", serializedObject, "charsLabel");

        if (NGUIEditorTools.DrawHeader("Name Label"))
        {
            NGUIEditorTools.BeginContents();
            EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
            {
                NGUIEditorTools.DrawProperty("Label", serializedObject, "nameLabel");

                if (mRealm.nameLabel != null)
                {
                    EditorGUILayout.Space();

                    SerializedObject obj = new SerializedObject(mRealm.nameLabel);
                    obj.Update();
                    NGUIEditorTools.DrawProperty("Normal Color", obj, "mColor");
                    obj.ApplyModifiedProperties();

                    NGUIEditorTools.DrawProperty("Hover Color", serializedObject, "nameHoverColor");
                    NGUIEditorTools.DrawProperty("Closed Color", serializedObject, "nameClosedColor");
                }
            }
            EditorGUI.EndDisabledGroup();
            NGUIEditorTools.EndContents();
        }

        if (NGUIEditorTools.DrawHeader("Status Label"))
        {
            NGUIEditorTools.BeginContents();
            EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
            {
                NGUIEditorTools.DrawProperty("Label", serializedObject, "statusLabel");

                if (mRealm.statusLabel != null)
                {
                    EditorGUILayout.Space();

                    NGUIEditorTools.DrawProperty("Online Color", serializedObject, "statusOnlineColor");
                    NGUIEditorTools.DrawProperty("Offline Color", serializedObject, "statusOfflineColor");
                }
            }
            EditorGUI.EndDisabledGroup();
            NGUIEditorTools.EndContents();
        }

        if (NGUIEditorTools.DrawHeader("Population Label"))
        {
            NGUIEditorTools.BeginContents();
            EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
            {
                NGUIEditorTools.DrawProperty("Label", serializedObject, "populationLabel");

                if (mRealm.populationLabel != null)
                {
                    EditorGUILayout.Space();

                    NGUIEditorTools.DrawProperty("Low Color", serializedObject, "popLowColor");
                    NGUIEditorTools.DrawProperty("Medium Color", serializedObject, "popMediumColor");
                    NGUIEditorTools.DrawProperty("High Color", serializedObject, "popHighColor");
                }
            }
            EditorGUI.EndDisabledGroup();
            NGUIEditorTools.EndContents();
        }

        if (NGUIEditorTools.DrawHeader("Closed Label"))
        {
            NGUIEditorTools.BeginContents();
            EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
            {
                NGUIEditorTools.DrawProperty("Closed Label", serializedObject, "closedLabel");

                if (mRealm.closedLabel != null)
                {
                    EditorGUILayout.Space();

                    SerializedObject obj = new SerializedObject(mRealm.closedLabel);
                    obj.Update();
                    NGUIEditorTools.DrawProperty("Normal Color", obj, "mColor");
                    obj.ApplyModifiedProperties();

                    NGUIEditorTools.DrawProperty("Hover Color", serializedObject, "closedHoverColor");
                }
            }
            EditorGUI.EndDisabledGroup();
            NGUIEditorTools.EndContents();
        }

        serializedObject.ApplyModifiedProperties();
    }