public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            ValidateProperty(property);
            label = EditorGUI.BeginProperty(position, label, property);

            var lv = EditorGUI.indentLevel;

            EditorGUI.BeginDisabledGroup(Application.isPlaying);

            EditorGUI.LabelField(position, DevilEditorUtility.EmptyContent, (GUIStyle)"helpbox");
            var row = new Rect(position.x + 3, position.y + 5, position.width - 6, 18);
            //EditorGUI.LabelField(row, DevilEditorUtility.EmptyContent, "helpbox");
            var s = Prop(p_comment).stringValue;

            s = EditorGUI.TextField(row, string.IsNullOrEmpty(s) ? comHint : s, DevilEditorUtility.HintStyle("label"));
            Prop(p_comment).stringValue = s == comHint ? "" : s;

            EditorGUI.indentLevel = lv;
            label.text            = " Varialbe Name";
            row.y += 20;
            var   pos  = EditorGUI.PrefixLabel(row, label);
            float size = pos.x - row.x;

            EditorGUI.indentLevel    = 0;
            Prop(p_name).stringValue = EditorGUI.TextField(pos, Prop(p_name).stringValue);

            EditorGUI.indentLevel = lv;
            row.y += 20;
            //label.text = " Data Type";
            pos = new Rect(row.x, row.y, size - 5, row.height);
            Prop(p_lst).boolValue = EditorGUI.Popup(pos, Prop(p_lst).boolValue ? 1 : 0, dtType, (GUIStyle)"ShurikenPopup") != 0;
            //pos = EditorGUI.PrefixLabel(row, label);
            pos = new Rect(row.x + size, row.y, row.width - size, row.height);

            EditorGUI.indentLevel = 0;
            var sel = GlobalUtil.FindIndex(AIModules.SharedTypeNames, (x) => x == Prop(p_type).stringValue);

            if (sel == -1)
            {
                sel = 0;
            }
            //pos.width -= 20;
            sel = EditorGUI.Popup(pos, sel, AIModules.SharedTypeNames, (GUIStyle)"ExposablePopupMenu");
            Prop(p_type).stringValue = AIModules.SharedTypeNames[sel];
            //pos = new Rect(pos.xMax + 3, pos.y, 15, 15);
            //Prop(p_lst).boolValue = EditorGUI.Toggle(pos, Prop(p_lst).boolValue, (GUIStyle)"MuteToggle");

            EditorGUI.indentLevel = lv;
            EditorGUI.EndDisabledGroup();
            EditorGUI.EndProperty();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            ValidateProperty(property);
            label = EditorGUI.BeginProperty(position, label, property);
            if (property.propertyType == SerializedPropertyType.Generic)
            {
                var pos = position;
                EditorGUI.LabelField(pos, DevilEditorUtility.EmptyContent, (GUIStyle)"helpbox");

                int lv = EditorGUI.indentLevel;

                var h = pos.height - 40;
                EditorGUI.indentLevel++;
                var rect = new Rect(pos.x, pos.y + 3, pos.width, h);
                EditorGUI.PropertyField(rect, Prop(p_value), label, true);

                rect                  = new Rect(pos.x, pos.y + h + 3, pos.width, pos.height - h);
                label.text            = " Blackboard Variable";
                position              = EditorGUI.PrefixLabel(rect, label);
                EditorGUI.indentLevel = 0;

                rect = new Rect(position.x, position.y, position.width, 18);
                var index = mSelectedIndex;
                mSelectedIndex = EditorGUI.Popup(rect, mSelectedIndex, mPopNames, (GUIStyle)"ExposablePopupMenu");
                if (mSelectedIndex > 0)
                {
                    Prop(p_name).stringValue = mPopNames[mSelectedIndex].text;
                    rect = new Rect(position.x, position.y + 18, position.width, 20);
                    EditorGUI.LabelField(rect, mVars[mSelectedIndex - 1].comment, DevilEditorUtility.HintStyle("label"));
                }
                else
                {
                    if (index > 0)
                    {
                        mCusCache = "";
                    }
                    rect      = new Rect(position.x, position.y + 18, position.width, 18);
                    mCusCache = EditorGUI.TextField(rect, mCusCache, (GUIStyle)"helpbox");
                    Prop(p_name).stringValue = mCusCache;
                }

                EditorGUI.indentLevel = lv;
            }
            else
            {
                EditorGUI.PropertyField(position, property);
            }
            //TextFieldDropDown TextFieldDropDownText
            EditorGUI.EndProperty();
        }
Пример #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, property);
            if (property.propertyType == SerializedPropertyType.String)
            {
                position = EditorGUI.PrefixLabel(position, label);
                int lv = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;


                var rect  = new Rect(position.x, position.y, position.width, 18);
                var index = mSelectedIndex;
                mSelectedIndex = EditorGUI.Popup(rect, mSelectedIndex, mPopNames, (GUIStyle)"ExposablePopupMenu");
                if (mSelectedIndex > 0)
                {
                    property.stringValue = mPopNames[mSelectedIndex].text;
                    rect = new Rect(position.x, position.y + 18, position.width, 20);
                    EditorGUI.LabelField(rect, mVars[mSelectedIndex - 1].comment, DevilEditorUtility.HintStyle("label"));
                }
                else
                {
                    if (index > 0)
                    {
                        mCusCache = "";
                    }
                    rect                 = new Rect(position.x, position.y + 18, position.width, 18);
                    mCusCache            = EditorGUI.TextField(rect, mCusCache, (GUIStyle)"helpbox");
                    property.stringValue = mCusCache;
                }

                EditorGUI.indentLevel = lv;
            }
            else
            {
                EditorGUI.PropertyField(position, property);
            }
            //TextFieldDropDown TextFieldDropDownText
            EditorGUI.EndProperty();
        }
 public override void OnInspectorGUI()
 {
     serializedObject.Update();
     if (target != null)
     {
         OnConditionGUI();
         DrawTitle();
         EditorGUILayout.BeginHorizontal("helpbox");
         comment = EditorGUILayout.TextArea(string.IsNullOrEmpty(comment) ? comHint : comment, DevilEditorUtility.HintStyle("label"), GUILayout.Height(50));
         EditorGUILayout.EndHorizontal();
         if (comment != comHint)
         {
             mComment.stringValue = comment;
         }
         else
         {
             mComment.stringValue = "";
         }
         serializedObject.ApplyModifiedProperties();
     }
     if (serializedObject != null)
     {
         base.OnInspectorGUI();
     }
 }
        public override void OnInspectorGUI()
        {
            TryGetMissingAssets();
            UpdateBinders();
            if (!string.IsNullOrEmpty(missAssets))
            {
                EditorGUILayout.HelpBox(missAssets, MessageType.Warning);
            }
            var tree = target as BehaviourTreeAsset;

            if (tree != null)
            {
                EditorGUILayout.BeginHorizontal("helpbox");
                var s = EditorGUILayout.TextArea(string.IsNullOrEmpty(tree.m_Comment) ? comHint : tree.m_Comment, DevilEditorUtility.HintStyle("label"), GUILayout.Height(120));
                if (s == comHint)
                {
                    tree.m_Comment = "";
                }
                else
                {
                    tree.m_Comment = s;
                }
                EditorGUILayout.EndHorizontal();
            }
            //EditorGUI.BeginDisabledGroup(true);
            //base.OnInspectorGUI();

            //EditorGUI.EndDisabledGroup();

            if (mServices.Count > 0)
            {
                EditorGUILayout.LabelField("服务", (GUIStyle)"LODLevelNotifyText", GUILayout.Height(30));
            }
            foreach (var t in mServices)
            {
                t.DrawGUI();
            }

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(40);

            var editing = BehaviourTreeEditor.ActiveBTEditor == null ? null : BehaviourTreeEditor.ActiveBTEditor.TargetTree;

            if (target != editing && GUILayout.Button("打开编辑器", "LargeButton"))
            {
                BehaviourTreeEditor.OpenBTEditor(target as BehaviourTreeAsset);
            }
            if (target != editing && GUILayout.Button("修复资源引用", "LargeButton"))
            {
                ((BehaviourTreeAsset)target).EditorResovleAsset();
                getMissAsset = true;
                if (BehaviourTreeEditor.ActiveBTEditor != null && BehaviourTreeEditor.ActiveBTEditor.Binder != null)
                {
                    BehaviourTreeEditor.ActiveBTEditor.Binder.Reset();
                }
            }
            GUILayout.Space(40);
            EditorGUILayout.EndHorizontal();
        }