Example #1
0
 /// <summary>
 /// シンボルスタイルオプションを表示します.
 /// ボタンを押した時にドロップダウンメニューを表示します.
 /// </summary>
 /// <param name="r">表示する座標.</param>
 /// <param name="symbol">表示するシンボル.</param>
 void DrawSymbolOption(Rect r, ScriptSymbolDefine.ScriptSymbol symbol)
 {
     //シンボルスタイル.
     if (GUI.Button(r, GUIContent.none, styleOption))
     {
         GenericMenu menu = new GenericMenu();
         menu.AddItem(new GUIContent("Delete"), false, () => {
             if (current && current.list.Contains(symbol))
             {
                 current.list.Remove(symbol);
             }
             EditorUtility.SetDirty(current);
         });
         foreach (ScriptSymbolDefine.Style style in System.Enum.GetValues(typeof(ScriptSymbolDefine.Style)))
         {
             menu.AddItem(new GUIContent("Style/" + style.ToString()), symbol.style == style
                          , _ => {
                 symbol.style = (ScriptSymbolDefine.Style)_;
                 EditorUtility.SetDirty(current);
             }
                          , style);
         }
         menu.DropDown(r);
     }
 }
Example #2
0
        /// <summary>シンボルを表示.</summary>
        void DrawSymbol(Rect rect, int index, bool isActive, bool isFocused)
        {
            ScriptSymbolDefine.ScriptSymbol symbol = ro.list [index] as ScriptSymbolDefine.ScriptSymbol;

            //GUIキャッシュ.
            if (styleToggle == null)
            {
                styleToggle = new GUIStyle("OL Toggle");
                styleToggle.focused.background = null;

                styleDescription          = new GUIStyle("HelpBox");
                styleDescription.richText = true;

                styleOption = new GUIStyle("PaneOptions");
                styleOption.imagePosition = ImagePosition.ImageOnly;

                styleName = new GUIStyle(EditorStyles.boldLabel);
            }

            //セパレータの場合、線引くだけ.
            if (symbol.style == ScriptSymbolDefine.Style.Separator)
            {
                GUI.Label(new Rect(rect.x + 20, rect.y + 24, rect.width - 40, 16), GUIContent.none, "sv_iconselector_sep");

                //シンボルスタイル.
                DrawSymbolOption(new Rect(rect.width + 10, rect.y + 4, 24, 24), symbol);
                return;
            }

            //シンボル表示.
            EditorGUI.BeginChangeCheck();
            {
                //背景&トグル.
                bool isGrouped = symbol.style != ScriptSymbolDefine.Style.Default;
                EditorGUI.BeginDisabledGroup(!symbol.enabled);
                {
                    GUI.Label(new Rect(rect.x, rect.y, rect.width, 16), GUIContent.none, "flow node " + (int)symbol.style);
                }
                EditorGUI.EndDisabledGroup();
                bool e = EditorGUI.Toggle(new Rect(rect.x + 5, rect.y - 1, 15, 16), symbol.enabled, isGrouped ? "Radio" : "Toggle");
                if (symbol.enabled != e)
                {
                    if (isGrouped)
                    {
                        foreach (var s in current.list.Where(_ => _.style == symbol.style))
                        {
                            s.enabled = false;
                        }
                        symbol.enabled = true;
                    }
                    else
                    {
                        symbol.enabled = e;
                    }
                }


                //シンボル名.
                string symbolNameId = string.Format("symbol neme {0}", index);
                GUI.SetNextControlName("DefineSymbolsEditor" + index);
                styleName.normal.textColor = !EditorGUIUtility.isProSkin ? Color.black : Color.white;
                EditorGUI.BeginDisabledGroup(!symbol.enabled);
                {
                    symbol.name = GUI.TextField(new Rect(rect.x + 21, rect.y, rect.width - 50, 16), symbol.name, styleName);
                }
                EditorGUI.EndDisabledGroup();

                //シンボルスタイル.
                DrawSymbolOption(new Rect(rect.width + 10, rect.y + 4, 24, 24), symbol);

                //シンボル説明.
                string symbolDescriptionId = string.Format("symbol desctription {0}", index);
                GUI.SetNextControlName(symbolDescriptionId);
                styleDescription.richText = GUI.GetNameOfFocusedControl() != symbolDescriptionId;
                symbol.description        = GUI.TextArea(new Rect(rect.x, rect.y + 16, rect.width, 32), symbol.description, styleDescription);

                //Addされたら自動で入力開始.
                if (addIndex == index)
                {
                    EditorGUI.FocusTextInControl(symbolNameId);
                    addIndex = -1;
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(current);
            }
        }