Esempio n. 1
0
        public override bool DrawItem(Rect position, int index, FieldRef o1, out FieldRef o2)
        {
            // invalidate obj if scene is changed
            if (obj is SceneAsset && assetPath == SceneManager.GetActiveScene().path)
            {
                obj = null;
            }

            if (obj == null)
            {
                if (scenePath == null)
                {
                    obj = AssetDatabase.LoadAssetAtPath <Object>(assetPath);
                }
                else if (assetPath == SceneManager.GetActiveScene().path)
                {
                    Transform t = scenePath.Find();
                    if (t != null)
                    {
                        if (DeclaringType == typeof(GameObject))
                        {
                            obj = t.gameObject;
                        }
                        else if (typeof(Component).IsAssignableFrom(DeclaringType))
                        {
                            var comps = t.GetComponents(DeclaringType);
                            if (compIndex < comps.Length)
                            {
                                obj = comps[compIndex];
                            }
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Can't find ref " + scenePath);
                    }
                }
                else
                {
                    obj = AssetDatabase.LoadAssetAtPath <Object>(assetPath);
                }
            }
            if (obj != null)
            {
                string displayName = scenePath == null?
                                     string.Format("{0} [{1}]", assetPath, GetSignature()) :
                                         string.Format("{0} [{1}]", scenePath, GetSignature());

                Rect[] rects = EditorGUILayoutEx.SplitRectHorizontally(position, 0.3f);
                EditorGUI.ObjectField(rects[0], obj, typeof(Object), true);
                EditorGUI.SelectableLabel(rects[1], displayName);
            }
            else
            {
                EditorGUI.SelectableLabel(position, ToString());
            }
            o2 = o1;
            return(false);
        }
Esempio n. 2
0
 public void OnGUI(Rect rect)
 {
     GUILayout.BeginVertical(AEStyles.box);
     win.config.firstStateName = EditorGUILayoutEx.DrawObject("起始状态名", win.config.firstStateName);
     GUILayout.EndVertical();
     GUILayout.Space(4);
     win.stateSelectIndex = EditorGUILayoutEx.DrawList(win.config.states, win.stateSelectIndex, ref scrollPos, NewState, ActionEditorUtility.StateDrawer);
 }
        public void OnSpyglassGUI()
        {
            var controller = AssetDatabase.LoadAssetAtPath <AnimatorController>(AssetDatabase.GetAssetPath(target.runtimeAnimatorController));

            if (controller == null)
            {
                return;
            }

            using (EditorGUILayoutEx.ScrollView(ref m_ScrollPosition))
            {
                using (GUILayoutEx.Vertical())
                {
                    foreach (AnimatorControllerParameter parameter in controller.parameters)
                    {
                        switch (parameter.type)
                        {
                        case AnimatorControllerParameterType.Float:
                        {
                            float value = target.GetFloat(parameter.name);
                            using (EditorGUIEx.ChangeCheck(() => target.SetFloat(parameter.name, value)))
                            {
                                value = EditorGUILayout.FloatField(parameter.name, value);
                            }
                        }
                        break;

                        case AnimatorControllerParameterType.Int:
                        {
                            int value = target.GetInteger(parameter.name);
                            using (EditorGUIEx.ChangeCheck(() => target.SetInteger(parameter.name, value)))
                            {
                                value = EditorGUILayout.IntField(parameter.name, value);
                            }
                        }
                        break;

                        case AnimatorControllerParameterType.Bool:
                        {
                            bool value = target.GetBool(parameter.name);
                            using (EditorGUIEx.ChangeCheck(() => target.SetBool(parameter.name, value)))
                            {
                                value = EditorGUILayout.Toggle(parameter.name, value);
                            }
                        }
                        break;

                        case AnimatorControllerParameterType.Trigger:
                            if (GUILayout.Button(parameter.name))
                            {
                                target.SetTrigger(parameter.name);
                            }
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Invoked in the Layout of each widget that has this component.
 /// </summary>
 /// <param name="style"></param>
 public override void DrawContent(ScriptForgeStyles style)
 {
     m_CreateEnum = EditorGUILayout.Toggle("Create Enum", m_CreateEnum);
     EditorGUI.BeginDisabledGroup(!m_CreateEnum);
     {
         m_EnumName = EditorGUILayoutEx.ClassNameTextField(ScriptForgeLabels.enumNameContent, m_EnumName, "Types");
     }
     EditorGUI.EndDisabledGroup();
 }
Esempio n. 5
0
 public override bool DrawValue(int i, E e)
 {
     if (EditorGUILayoutEx.Popup <E>(ref e, preset, layout))
     {
         this[i] = e;
         return(true);
     }
     return(false);
 }
Esempio n. 6
0
        public static void RangeConfigDrawer(int index, ref bool selected, RangeConfig obj)
        {
            if (GUILayout.Button($"{index}", selected ? AEStyles.item_head_select : AEStyles.item_head_normal, GUILayout.ExpandHeight(true), GUILayout.Width(15)))
            {
                GUI.FocusControl(null);
                selected = !selected;
            }

            EditorGUILayoutEx.DrawObject(GUIContent.none, obj);
        }
Esempio n. 7
0
 public override void OnHeaderGUI(List <ShaderSearchItem> found)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayoutEx.TextField(null, ref shaderName);
     if (GUILayout.Button("Search"))
     {
         Search();
     }
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 8
0
        public override void OnHeaderGUI(List <Collider> found)
        {
            var cams = Camera.allCameras;

            if (cams.Length == 1)
            {
                cam = cams[0];
            }
            EditorGUILayoutEx.Popup <Camera>("Camera", ref cam, cams);
        }
Esempio n. 9
0
 public override bool DrawItem(Rect rect, int index, ShaderSearchItem item, out ShaderSearchItem newItem)
 {
     Rect[] area1 = EditorGUILayoutEx.SplitRectHorizontally(rect, 0.5f);
     Rect[] area2 = EditorGUILayoutEx.SplitRectHorizontally(area1[1], 0.5f);
     EditorGUI.SelectableLabel(area1[0], item.name);
     EditorGUI.ObjectField(area2[0], item.rend, typeof(Object), true);
     EditorGUI.ObjectField(area2[1], item.material, typeof(Material), true);
     newItem = item;
     return(false);
 }
Esempio n. 10
0
        protected override bool OnInspectorGUI(T obj, int i)
        {
            float width = GetWidth();

            if (EditorGUILayoutEx.ObjectField <T>(ref obj, allowSceneObj, GUILayout.MinWidth(width * 0.4F)))
            {
                this[i] = obj;
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
        public override bool DrawValue(int i, EnumWrapper w)
        {
            E e = (E)Enum.Parse(typeof(E), w.Enum.ToString());

            if (EditorGUILayoutEx.Popup <E>(ref e, preset, layout))
            {
                w.Enum = (Enum)Enum.Parse(typeof(E), e.ToString());
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
 private void DrawPrebuildScript()
 {
     if (EditorUI.DrawHeader("Build Scripts"))
     {
         EditorUI.BeginContents();
         EditorGUILayout.BeginHorizontal();
         if (EditorGUILayoutEx.TextField("Prebuild Method", ref prebuildMethod))
         {
             EditorPrefs.SetString(PREBUILD_METHOD_PREF, prebuildMethod);
         }
         if (GUILayout.Button("Run", GUILayout.ExpandWidth(false)))
         {
             try
             {
                 ReflectionUtil.ExecuteMethod(prebuildMethod);
                 EditorUtility.DisplayDialog("Done", "Run Prebuild Method success", "OK");
             } catch (Exception ex)
             {
                 Debug.LogError(ex.ToString());
                 EditorUtility.DisplayDialog("Error", ex.Message, "OK");
             }
         }
         EditorGUILayout.EndHorizontal();
         if (EditorGUILayoutEx.TextArea("Prebuild Script", ref prebuildScript, GUILayout.Height(50)))
         {
             EditorPrefs.SetString(PREBUILD_SCRIPT_PREF, prebuildScript);
         }
         EditorGUILayout.BeginHorizontal();
         if (EditorGUILayoutEx.TextField("Postbuild Method", ref postbuildMethod))
         {
             EditorPrefs.SetString(POSTBUILD_METHOD_PREF, postbuildMethod);
         }
         if (GUILayout.Button("Run", GUILayout.ExpandWidth(false)))
         {
             ReflectionUtil.ExecuteMethod(postbuildMethod);
             EditorUtility.DisplayDialog("Done", "Run PostBuild Method success", "OK");
         }
         EditorGUILayout.EndHorizontal();
         if (prebuildOutput != null)
         {
             if (prebuildOutput.IsError())
             {
                 MarkError();
             }
             string result = prebuildOutput.GetResult();
             EditorGUILayoutEx.TextArea("Prebuild Result", ref result, GUILayout.Height(100));
             if (prebuildOutput.IsError())
             {
                 ClearError();
             }
         }
         EditorUI.EndContents();
     }
 }
Esempio n. 13
0
        public bool DrawComponentPopup(ref GameObject obj, ref MonoBehaviour comp)
        {
            bool changed = EditorGUILayoutEx.ObjectField <GameObject>("GameObject", ref obj, true);

            if (obj != null)
            {
                MonoBehaviour[] comps = obj.GetComponents <MonoBehaviour>();
                changed |= EditorGUILayoutEx.PopupNullable <MonoBehaviour>(null, ref comp, comps, ToStringScript);
            }
            return(changed);
        }
Esempio n. 14
0
        private void PlayMode()
        {
            win.setting.showView = EditorGUILayoutEx.DrawObject("显示", win.setting.showView);
            GUILayout.FlexibleSpace();

            string[] configNames = ActionMachineHelper.loadedConfig.Keys.ToArray();
            if (configNames == null || configNames.Length == 0)
            {
                selectConfigName = string.Empty;

                GUILayout.Label("当前没有已加载的配置文件");
                return;
            }

            bool isInit = true;
            int  index  = 0;

            if (!string.IsNullOrEmpty(selectConfigName))
            {
                index = Array.FindIndex(configNames, t => string.Compare(t, selectConfigName) == 0);
                if (index < 0)
                {
                    index = 0;
                }
            }
            else
            {
                isInit = false;
            }

            GUILayout.Label("已加载配置文件");

            EditorGUI.BeginChangeCheck();
            index = EditorGUILayout.Popup(GUIContent.none, index, configNames, GUILayout.Width(200f));
            if (EditorGUI.EndChangeCheck() || !isInit)
            {
                selectConfigName = configNames[index];

                MachineConfig config = ActionMachineHelper.loadedConfig[selectConfigName];
                win.config = config;
            }

            if (GUILayout.Button("覆盖到", GUILayout.Width(80)))
            {
                GUI.FocusControl(null);
                SaveConfigToSelect(win.config);
            }
            if (GUILayout.Button("另存到", GUILayout.Width(100)))
            {
                GUI.FocusControl(null);
                CopyToNew(win.config);
            }
        }
Esempio n. 15
0
 public bool DrawFieldPopup(Type type, ref FieldInfo field)
 {
     ListFields(type);
     if (fieldArr != null)
     {
         if (EditorGUILayoutEx.PopupNullable <FieldInfo>("Field Name", ref field, fieldArr, FieldToString))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 16
0
 public override void OnFooterGUI(List <Object> found)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayoutEx.ObjectField <Object>("Value", ref rhsObj, true);
     GUI.enabled = searchObj != null && rhsObj != null && searchObj.GetType() == rhsObj.GetType() && allocInfo.Count > 0;
     if (GUILayout.Button("Allocate"))
     {
         Allocate();
     }
     EditorGUILayout.EndHorizontal();
     GUI.enabled = true;
 }
Esempio n. 17
0
 public bool DrawPropertyPopup(Type type, ref PropertyInfo prop)
 {
     ListFields(type);
     if (propArr != null)
     {
         if (EditorGUILayoutEx.PopupNullable <PropertyInfo>("Property Name", ref prop, propArr, PropertyToString))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 18
0
 private void DrawEnum <T>(string title, T e1, ref T e2) where T : struct, IComparable, IConvertible, IFormattable
 {
     if (!e1.Equals(e2))
     {
         SetBackgroundColor(Color.red);
         EditorGUILayoutEx.PopupEnum(title, ref e2);
         ResetBackgroundColor();
     }
     else
     {
         EditorGUILayoutEx.PopupEnum(title, ref e2);
     }
 }
Esempio n. 19
0
 private void DrawInt(string title, int i1, ref int i2)
 {
     if (i1 != i2)
     {
         MarkError();
         EditorGUILayoutEx.IntField(title, ref i2);
         ClearError();
     }
     else
     {
         EditorGUILayoutEx.IntField(title, ref i2, EditorStyles.toolbarTextField);
     }
 }
Esempio n. 20
0
        protected override void OnGUI(Rect rect)
        {
            object obj = win.currentGlobalAction;

            if (null == obj)
            {
                return;
            }

            scrollView = EditorGUILayout.BeginScrollView(scrollView);
            EditorGUILayoutEx.DrawObject(GUIContent.none, obj, obj.GetType());
            EditorGUILayout.EndScrollView();
        }
Esempio n. 21
0
 private void DrawString(string title, string s1, ref string s2)
 {
     if (s1 != s2)
     {
         MarkError();
         EditorGUILayoutEx.TextField(title, ref s2, GUILayout.ExpandWidth(true));
         ClearError();
     }
     else
     {
         EditorGUILayoutEx.TextField(title, ref s2, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true));
     }
 }
        private void OnGUI()
        {
            GUILayout.BeginHorizontal();
            {
#if !ODIN_INSPECTOR
                GUILayout.Label("缺少Odin!");
#endif

#if ODIN_INSPECTOR
                EXPORT_PATH = BApplication.DevOpsPublishAssetsPath;
                if (editorScript != null)
                {
                    //GUILayout.BeginVertical();
                    SirenixEditorGUI.BeginBox("脚本", true, GUILayout.Width(220), GUILayout.Height(450));
                    editorScript.OnGUI();
                    SirenixEditorGUI.EndBox();
                    //GUILayout.EndVertical();
                }

                // Layout_DrawLineV(Color.white);

                if (editorAsset != null)
                {
                    SirenixEditorGUI.BeginBox("资源", true, GUILayout.Width(220), GUILayout.Height(450));
                    editorAsset.OnGUI();
                    SirenixEditorGUI.EndBox();
                }

                // Layout_DrawLineV(Color.white);
                if (editorTable != null)
                {
                    SirenixEditorGUI.BeginBox("表格", true, GUILayout.Width(200), GUILayout.Height(450));
                    editorTable.OnGUI();
                    SirenixEditorGUI.EndBox();
                    //Layout_DrawLineV(Color.white);
                }
#endif
            }
            GUILayout.EndHorizontal();


            EditorGUILayoutEx.Layout_DrawLineH(Color.white);
            //绘制一键导出和构建Editor WebServer
            GUILayout.BeginHorizontal();
            OnGUI_OneKeyExprot();
            EditorGUILayoutEx.Layout_DrawLineV(Color.white);
            OnGUI_PublishEditorService();
            GUILayout.EndHorizontal();
        }
Esempio n. 23
0
        private void EditorMode()
        {
            Event evt = Event.current;

            if (GUILayout.Button("保存", GUILayout.Width(80)))
            {
                SaveConfig();
                GUI.FocusControl(null);
            }
            if (GUILayout.Button("还原修改", GUILayout.Width(80)))
            {
                GUI.FocusControl(null);
                ResetConfig();
            }
            if (GUILayout.Button("拷贝配置", GUILayout.Width(80)))
            {
                GUI.FocusControl(null);
                CopyConfig();
            }
            if (GUILayout.Button("粘贴配置", GUILayout.Width(80)))
            {
                GUI.FocusControl(null);
                PasteConfig();
            }

            win.setting.showView = EditorGUILayoutEx.DrawObject("显示", win.setting.showView);

            GUILayout.FlexibleSpace();

            EditorGUI.BeginChangeCheck();
            win.actionMachineObj = (GameObject)EditorGUILayout.ObjectField(win.actionMachineObj, typeof(GameObject), true);
            if (EditorGUI.EndChangeCheck() && win.actionMachineObj != null)
            {
                win.UpdateTarget(win.actionMachineObj);
            }

            EditorGUI.BeginChangeCheck();
            win.configAsset = (TextAsset)EditorGUILayout.ObjectField(win.configAsset, typeof(TextAsset), false);
            if (EditorGUI.EndChangeCheck())
            {
                win.UpdateConfig(win.configAsset);
            }

            if (GUILayout.Button("创建", GUILayout.Width(80)))
            {
                GUI.FocusControl(null);
                CreateNew();
            }
        }
Esempio n. 24
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Rect typePos = new Rect(position.x, position.y, 80, position.height);

            position.xMin = typePos.xMax;
            Rect varPos = new Rect(position.x, position.y, position.width, position.height);


            Type type = Type.GetType(property.type);

            //create types selection popup
            //if ( selectedType == typeof(System.Object)) {
            if (property.objectReferenceValue == null)
            {
                type = EditorGUILayoutEx.unityTypes [0];
            }
            else
            {
                type = ((UnityVariable)property.objectReferenceValue).ValueType;
            }


            String name        = ((UnityVariable)property.objectReferenceValue).name;
            bool   typeChanged = false;

            EditorGUI.BeginChangeCheck();
            typeSelected = EditorGUILayoutEx.CustomObjectPopup <Type> (null, type, EditorGUILayoutEx.unityTypesDisplayOptions, EditorGUILayoutEx.unityTypes, null, null, null, null, typePos);

            //if change of type create new variable
            if (typeSelected != type && !typeSelected.IsSubclassOf(type) /*&& type!=typeof(UnityEngine.Object)*/)
            {
                property.objectReferenceValue = UnityVariable.CreateInstanceOf(typeSelected);
                typeChanged = true;
            }
            //	}

            property.objectReferenceValue = EditorGUILayoutEx.UnityVariablePopup(null, property.objectReferenceValue as UnityVariable, typeSelected, new List <GUIContent>(), new List <UnityVariable>(), varPos);

            UnityVariable variable = ((UnityVariable)property.objectReferenceValue);

            variable.drawer = this;
            variable.name   = name;

            if (EditorGUI.EndChangeCheck() || typeChanged)
            {
                property.serializedObject.ApplyModifiedProperties();
                //EditorUtilityEx.ApplySerializedPropertyTo(variable);
            }
        }
Esempio n. 25
0
        public void OnGUI(Rect rect)
        {
            List <RangeConfig> configs = win.currentAttackRanges;

            if (null == configs)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            win.attackRangeSelectIndex = EditorGUILayoutEx.DrawList(configs, win.attackRangeSelectIndex, ref scrollPos, NewRange, ActionEditorUtility.RangeConfigDrawer);
            if (EditorGUI.EndChangeCheck())
            {
                //win.configModification = true;
            }
        }
Esempio n. 26
0
        /**
         * Draw Enum Popup UI if the enum class source is set correctly
         */
        public bool OnInspectorGUI(ref string str, params GUILayoutOption[] options)
        {
            string val     = str;
            bool   changed = false;

            if (enums == null || enums.Length == 0)
            {
                changed |= EditorGUILayoutEx.TextField(null, ref val, options);
            }
            else
            {
                changed |= EditorGUILayoutEx.PopupNullable <string>(null, ref val, enums, options);
            }
            str = val;
            return(changed);
        }
Esempio n. 27
0
        public void OnGUI(Rect rect)
        {
            List <object> configs = win.currentActions;

            if (null == configs)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();

            win.actionSelectIndex = EditorGUILayoutEx.DrawList(configs, win.actionSelectIndex, ref scrollPos, NewAction, ActionEditorUtility.ItemDrawer);
            if (EditorGUI.EndChangeCheck())
            {
                //win.configModification = true;
            }
        }
        private void OnGUI()
        {
            var allconfigs = HotfixPipelineTools.HotfixFileConfig.GetAllConfig();

            if (curSlectConfigItem == null && allconfigs.Length > 0)
            {
                curSlectConfigItem = allconfigs[0];
            }

            //绘制config
            ONGUI_DrawAllConfig();
            //排版
            EditorGUILayoutEx.Layout_DrawLineH(new Color(1, 1, 1, 0.5f), 2);
            GUILayout.BeginVertical();
            ONGUI_DrawFileList();
            GUILayout.EndVertical();
        }
Esempio n. 29
0
        protected override bool OnInspectorGUI(string obj, int i)
        {
            float width = GetWidth();

            if (preset != null)
            {
                if (EditorGUILayoutEx.PopupNullable <string>(null, ref obj, preset, GUILayout.MinWidth(width * 0.4F)))
                {
                    this[i] = obj;
                    return(true);
                }
            }
            else if (DrawEnum(ref obj, GUILayout.MinWidth(width * 0.4F)))
            {
                this[i] = obj;
                return(true);
            }
            return(false);
        }
Esempio n. 30
0
        public virtual void OnSpyglassGUI()
        {
            if (targets.Length > 1)
            {
                using (EditorGUILayoutEx.Vertical())
                {
                    GUILayout.Label("Object distances:");
                    foreach (Object[] o in targets.Tuples(2))
                    {
                        Transform[] t = o.Cast <Transform>().ToArray();

                        using (EditorGUILayoutEx.Horizontal())
                        {
                            EditorGUILayout.SelectableLabel("{0} <> {1}: {2}".format(t[0].name, t[1].name, Vector3.Distance(t[0].position, t[1].position)));
                        }
                    }
                }
            }
        }