HelpBox() public static method

Make a help box with a message to the user.

public static HelpBox ( string message, MessageType type ) : void
message string The message text.
type MessageType The type of message.
return void
示例#1
0
        string InspectTags(string tags)
        {
            if (tags == null)
            {
                tags = "";
            }

            tags = EGL.TextField("Tags", tags);
            string[] splitted = tags.Split(',');

            var invalidTags = "";

            foreach (var tag in splitted)
            {
                if (tag.Length > 0 && !state.profile.tags.Contains(tag))
                {
                    invalidTags += tag;
                    invalidTags += '|';
                }
            }

            if (invalidTags.Length != 0)
            {
                EGL.HelpBox("Tag |" + invalidTags + " are invalid.", MessageType.Error);
            }

            return(tags);
        }
示例#2
0
        private void OnGUI()
        {
            if (EntityManager == null)
            {
                EditorGUILayout.HelpBox("please set EntityManager -> BuffDebugWindow.EntityManager",
                                        MessageType.Warning);
                return;
            }

            var entitys = EntityManager.Entitys;

            EditorGUILayout.LabelField("Entity count:" + entitys.Count);

            EditorGUI.indentLevel++;
            _pos = EditorGUILayout.BeginScrollView(_pos, "box");
            {
                foreach (var entity in entitys)
                {
                    EditorGUILayout.LabelField($"{entity} Buff Count:" +
                                               EntityManager.GetAllBuff(entity).Count());
                }
            }
            EditorGUILayout.EndScrollView();
            EditorGUI.indentLevel--;

            Repaint();
        }
示例#3
0
    public override void OnInspectorGUI()
    {
        var script = (BehaviourScript)target;

        if (script.compileOkay)
        {
            EGL.HelpBox("The script is compiled and up to date!", MessageType.Info);
        }
        if (script.notUpToDate)
        {
            EGL.HelpBox("The compiled script is not up to date.", MessageType.Warning);
        }
        if (script.notCompiled)
        {
            EGL.HelpBox("The script is not yet compiled.", MessageType.Error);
        }

        if (GL.Button("Compile"))
        {
            script.Compile();
        }

        if (GL.Button("Print AST"))
        {
            script.PrintAST();
        }
    }
示例#4
0
        private void DrawAssurer(VAssetManager Manager)
        {
            GL.BeginVertical("OL box");
            GL.Label(Manager.ManagerName);
            var list = Manager.GetAssurerList();

            if (list.Count == 0)
            {
                EGL.HelpBox("暂无资产", MessageType.Info);
            }
            else
            {
                list.ForEach(assurer =>
                {
                    GL.BeginVertical("GroupBox");
                    GL.BeginHorizontal();
                    GL.Label(String.Format("{0} : Ref {1}", assurer.Value.AssetPath, assurer.Value.UseCount));
                    if (GL.Button("Kill", GUILayout.Width(100)))
                    {
                        assurer.Value.ForceRecycle();
                    }
                    GL.EndHorizontal();
                    GL.EndVertical();
                    GL.Space(2);
                });
            }



            GL.EndVertical();
        }
示例#5
0
        public void DrawLuaScript(string filePath)
        {
            FindLuaTableInfo(filePath);
            // 以上是初始化环节
            var luaName = filePath.Substring(filePath.LastIndexOf("/") + 1, filePath.Length - filePath.LastIndexOf("/") - 1).Replace(".lua", "");

            GL.BeginVertical("OL box");
            GL.Label(luaName, EditorStyles.boldLabel);
            if (mExecuteFunctionDirt == null || mExecuteFunctionDirt.Count() < 1)
            {
                EGL.HelpBox("没有可以被执行的方法", MessageType.Warning);
            }
            else
            {
                foreach (var m in mExecuteFunctionDirt)
                {
                    GL.BeginHorizontal("box");
                    var methodName = string.Format("{0}:{1}", luaName, m.Key);
                    GL.Label(methodName);
                    if (GL.Button("Execute", GUILayout.Width(100)))
                    {
                        UnityEngine.Debug.LogFormat("<color=#FFA80B>Execute {0}:{1}</color>", luaName, m.Key);
                        m.Value.Invoke();
                    }
                    GL.EndHorizontal();
                    GL.Space(2);
                }
            }
            GL.EndVertical();
        }
示例#6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var tree   = (BehaviourTree)target;
            var script = tree.source;

            if (script)
            {
                if (script.notCompiled)
                {
                    EGL.HelpBox("Script is not compiled.", MessageType.Error);
                }
                if (script.notUpToDate)
                {
                    EGL.HelpBox("Script is not up to date.", MessageType.Warning);
                }
                if (script.compileOkay)
                {
                    EGL.HelpBox("Script is compiled and up to date.", MessageType.Info);
                }
                if (GL.Button("Compile"))
                {
                    script.Compile();
                }
            }

            if (Application.isPlaying)
            {
                EGL.Space();
                EGL.LabelField("Conditions");
                GUI.enabled = false;
                foreach (var cond in tree.blackboard)
                {
                    var k = cond.Key;
                    var v = cond.Value;
                    if (v is float)
                    {
                        EGL.FloatField(k, (float)v);
                    }
                    else if (v is int)
                    {
                        EGL.IntField(k, (int)v);
                    }
                    else if (v is bool)
                    {
                        EGL.Toggle(k, (bool)v);
                    }
                    else if (v is string)
                    {
                        EGL.TextField(k, (string)v);
                    }
                }
                GUI.enabled = true;
                Repaint();
            }
        }
示例#7
0
        private void DrawScript(Type t)
        {
            var att = t.RTGetAttribute <QuickExecuteAttribute>(false);

            if (att == null)
            {
                return;
            }
            GL.BeginVertical("OL box");
            GL.Label(t.Name, EditorStyles.boldLabel);
            var methods = t.GetMethods().Where((i) => { return(i.RTGetAttribute <ExecuteMethodAttribute>(false) != null); });

            if (methods.Count() < 1)
            {
                EGL.HelpBox("没有可以被执行的方法(请检查是否添加了[ExecuteMethodAttribute])", MessageType.Warning);
            }
            else
            {
                foreach (var m in methods)
                {
                    GL.Space(2);
                    GL.BeginHorizontal();
                    var methodName = m.Name + ":(";
                    var param      = m.GetParameters();
                    for (int i = 0; i < param.Length; i++)
                    {
                        var p = param[i];
                        if (i != param.Length - 1)
                        {
                            methodName += string.Format("<b>{0}</b> , ", p.ToString());
                        }
                        else
                        {
                            methodName += string.Format("<b>{0}</b>", p.ToString());
                        }
                    }
                    methodName += ")";
                    GL.Label(methodName);
                    if (GL.Button("Execute", GUILayout.Width(100)))
                    {
                        var o = ReflectionTools.CreateObject(t);
                        //TODO 扩展编辑参数
                        if (param.Length == 0)
                        {
                            m.Invoke(o, null);
                        }
                        Log.I(string.Format("<color=#FFA80B>Execute {0}</color>", methodName));
                    }
                    GL.EndHorizontal();
                    GL.Space(2);
                }
            }
            GL.EndVertical();
        }
示例#8
0
        void FromStateFilterInspector(TransitionProfile profile, FromStateFilter filter, ref Rect stateRect)
        {
            EGL.BeginHorizontal();
            filter.type = (FromStateType)EGL.EnumPopup(filter.type, GL.Width(70));

            if (filter.type == FromStateType.State)
            {
                EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, allStateNames, str => filter.stateOrTagName = str, ref stateRect);
            }
            else if (filter.type == FromStateType.Tag)
            {
                EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, transition.profile.tags, str => filter.stateOrTagName = str, ref stateRect);
            }

            if (filter.type == FromStateType.State)
            {
                var state = transition.profile.FindState(filter.stateOrTagName);
                if (state == null)
                {
                    EGL.EndHorizontal();
                    EGL.HelpBox("No Source State", MessageType.Error);
                }
                else
                {
                    List <string> portionSelections = new List <string>();
                    portionSelections.Add("<any>");
                    foreach (var p in state.allPortions)
                    {
                        portionSelections.Add(p.name);
                    }

                    var prevIndex = portionSelections.IndexOf(filter.portionName);
                    if (prevIndex == -1)
                    {
                        prevIndex = 0;
                    }

                    prevIndex          = EGL.Popup(prevIndex, portionSelections.ToArray());
                    filter.portionName = prevIndex == 0 ? "" : portionSelections[prevIndex];

                    if (GL.Button("Focus"))
                    {
                        Utils.FocusEditingAnimation(profile, state.stateName);
                    }
                    EGL.EndHorizontal();
                }
            }
            else
            {
                EGL.EndHorizontal();
            }
        }
示例#9
0
        private void OnGUI()
        {
            if (!File.Exists(PackageFilePath))
            {
                EGL.HelpBox("暂无数据", MessageType.Warning);
                return;
            }

            GUI.skin.label.richText = true;
            scrollRect = GL.BeginScrollView(scrollRect, "box");
            DrawDatas();
            GL.EndScrollView();
        }
示例#10
0
 private void OnGUI()
 {
     if (!Application.isPlaying)
     {
         EGL.HelpBox("未运行", MessageType.Warning);
         return;
     }
     GUI.skin.label.richText = true;
     scrollRect = GL.BeginScrollView(scrollRect, "box");
     DrawAssurer(ABManager.Instance);
     DrawAssurer(ResManager.Instance);
     DrawAssurer(NetAssetManager.Instance);
     GL.EndScrollView();
 }
示例#11
0
        private void OnGUI()
        {
            GUI.skin.label.richText = true;

            if (GL.Button("Search Can Execute Script"))
            {
                searchScript = true;
                DoSearch();
            }
            if (searchScript == true)
            {
                DrawSearchResult();
            }
            if (focusFileName.IsNullOrEmpty())
            {
                DrawDragSpace();
            }
            else
            {
                GL.Space(5);
                GL.BeginVertical("box");
                GL.Label(string.Format("FocusFileName : {0}", focusFileName), EditorStyles.boldLabel);
                GL.Label(string.Format("FocusFileType : {0}", focusFileType.ToString()), EditorStyles.boldLabel);
                GL.Label(string.Format("FocusFilePath : {0}", focusFilePath), EditorStyles.boldLabel);
                focusFileRect = GL.BeginScrollView(focusFileRect, "box");
                if (focusFileType == QEType.CSharp)
                {
                    DrawScript(GetFocusFileType(focusFileName));
                }
                if (focusFileType == QEType.Lua)
                {
                                        #if LUA_KIT
                    luaVeiwer.DrawLuaScript(focusFilePath);
                                        #else
                    EGL.HelpBox("没有LUA_KIT环境,请查看说明", MessageType.Warning);
                                        #endif
                }
                if (GL.Button("ClearFocus"))
                {
                    ClearFocusFile();
                }
                GL.EndScrollView();
                GL.EndVertical();
            }
        }
示例#12
0
        protected override void OnSettingsGUI()
        {
            GUILayout.Label("Collapse Vertices Settings", EditorStyles.boldLabel);

            EditorGUILayout.HelpBox("Collapse To First setting decides where the collapsed vertex will be placed.\n\nIf True, the new vertex will be placed at the position of the first selected vertex.  If false, the new vertex is placed at the average position of all selected vertices.", MessageType.Info);

            EditorGUI.BeginChangeCheck();

            m_CollapseToFirst.value = EditorGUILayout.Toggle("Collapse To First", m_CollapseToFirst);

            if (EditorGUI.EndChangeCheck())
            {
                ProBuilderSettings.Save();
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Collapse Vertices"))
            {
                DoAction();
            }
        }
        protected override void OnSettingsGUI()
        {
            GUILayout.Label("Fill Hole Settings", EditorStyles.boldLabel);

            EditorGUILayout.HelpBox("Fill Hole can optionally fill entire holes (default) or just the selected vertices on the hole edges.\n\nIf no elements are selected, the entire object will be scanned for holes.", MessageType.Info);

            EditorGUI.BeginChangeCheck();

            m_SelectEntirePath.value = EditorGUILayout.Toggle("Fill Entire Hole", m_SelectEntirePath);

            if (EditorGUI.EndChangeCheck())
            {
                ProBuilderSettings.Save();
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Fill Hole"))
            {
                EditorUtility.ShowNotification(PerformAction().notification);
            }
        }
示例#14
0
    private void OnGUI()
    {
        UG.BeginVertical();

        chosenMeshGenerationType = (MeshGenerationType)UG.EnumPopup("网格生成类型", chosenMeshGenerationType);
        defaultMaterial          = UG.ObjectField("默认材质", defaultMaterial, typeof(Material), false) as Material;

        switch (chosenMeshGenerationType)
        {
        case MeshGenerationType.Plane: OnPlaneGenerationGUI(); break;

        case MeshGenerationType.Box: OnBoxGenerationGUI(); break;

        case MeshGenerationType.Slope: OnSlopeGenerationGUI(); break;

        case MeshGenerationType.VolumetricFluid: OnVolumetricFluidGenerationGUI(); break;

        default: UG.HelpBox("需要选择一种网格生成类别进行编辑!", MessageType.Warning); break;
        }

        UG.EndVertical();
    }
示例#15
0
    void OnGUI()
    {
        EGL.LabelField("3D Texture properties", EditorStyles.boldLabel);

        int new_size = EGL.IntField("Resolution", data.size);

        new_size  = new_size <= 512 ? new_size : 512;
        new_size  = new_size >= 8 ? new_size : 8;
        data.size = new_size;

        EGL.LabelField("Worley noise");
        data.freqs[0]   = EGL.FloatField("Frequency", data.freqs[0]);
        data.octaves[0] = EGL.IntField("Octaves", data.octaves[0]);
        bool inv = EGL.Toggle("Invert", data.inverts[0] > 0);

        data.inverts[0] = inv ? 1 : 0;

        if (GUILayout.Button("Generate"))
        {
            CreateTexture();
        }

        EGL.HelpBox(status, MessageType.None, true);

        if (GUILayout.Button("Preview"))
        {
            CloudPreviewer.ShowTexture(texture);
        }

        EGL.BeginHorizontal();
        assetName = EGL.TextField("Asset name:", assetName);
        if (GUILayout.Button("Save"))
        {
            AssetDatabase.CreateAsset(texture, "Assets/" + assetName + ".asset");
        }
        EGL.EndHorizontal();
    }
示例#16
0
        public override void OnInspectorGUI()
        {
            bool targetChanged = false;

            if (target != state)
            {
                addStatePortionName = "";
                targetChanged       = true;
            }
            state = (State)target;

            if (targetChanged)
            {
                var layer     = state.profile.controller.layers[state.profile.controllerLayer];
                var animState = Utils.FindState(layer.stateMachine, state.stateName);
                clip = animState.motion as AnimationClip;

                var sb = new System.Text.StringBuilder();

                var events = AnimationUtility.GetAnimationEvents(clip);
                sb.AppendFormat("Events ({0}) ", events.Length).AppendLine();
                if (events.Length > 0)
                {
                    foreach (var ev in events)
                    {
                        sb.Append(string.Format("{0,4}", (int)FrameUtil.Time2Frame(ev.time))).Append("F ");
                        sb.Append(ev.functionName);
                        sb.AppendLine();
                    }
                }
                sb.AppendLine();

                var bindings = AnimationUtility.GetCurveBindings(clip);
                sb.AppendFormat("Bindings ({0})", bindings.Length).AppendLine();
                foreach (var binding in bindings)
                {
                    sb.Append("  ").Append(binding.path).Append(binding.path == "" ? "" : "/")
                    .Append("<").Append(binding.type.Name).Append(">.")
                    .Append(binding.propertyName).AppendLine();
                }

                summary = sb.ToString();
            }

            EditorGUI.BeginChangeCheck();

            EGL.LabelField("Name", state.stateName);
            EGL.LabelField("Frames", state.frames.ToString());

            bool lastGUIEnabled = GUI.enabled;

            GUI.enabled = false;
            EGL.ObjectField("Clip", clip, typeof(AnimationClip), allowSceneObjects: false);
            GUI.enabled = lastGUIEnabled;

            if (summary.Length > 0)
            {
                EGL.HelpBox(summary, MessageType.None);
            }

            state.tags = InspectTags(state.tags);
            EGL.Space();

            using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                ++EditorGUI.indentLevel;
                InspectBehaviourList(state.behaviours);
                --EditorGUI.indentLevel;
                EGL.Space();
            }

            EGL.LabelField("Portions");
            var portions = state.portions;

            for (int i = 0; i < portions.Count; ++i)
            {
                var portion = portions[i];

                bool active = activePortions.Contains(portion);
                active = EGL.Foldout(active, portion.name);
                if (active)
                {
                    activePortions.Add(portion);
                }
                else
                {
                    activePortions.Remove(portion);
                }

                if (active)
                {
                    ++EditorGUI.indentLevel;

                    EGL.BeginHorizontal();
                    portion.name = EGL.TextField("Name", portion.name);
                    // GL.FlexibleSpace();
                    if (GL.Button("-", GUILayout.Width(30)))
                    {
                        portions.RemoveAt(i);
                        --i;
                    }
                    EGL.EndHorizontal();

                    portion.range      = EditorGUIUtil.FrameRangeSlider("Range", portion.range, state.frames);
                    portion.includeEnd = EGL.Toggle("Include nt>=1", portion.includeEnd);
                    portion.tags       = InspectTags(portion.tags);

                    using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                        InspectBehaviourList(portion.behaviours);
                    }

                    --EditorGUI.indentLevel;
                }
            }

            EGL.Space();
            EGL.Space();
            EGL.BeginHorizontal();
            addStatePortionName = EGL.TextField(addStatePortionName);
            if (GUI.enabled && GL.Button("Add Portion", GL.Width(90)))
            {
                var portion = new StatePortion {
                    name = addStatePortionName
                };
                portions.Add(portion);

                addStatePortionName = "";
            }
            EGL.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(state);
            }
        }
示例#17
0
 public override void OnInspectorGUI()
 {
     if (!this.m_FormatSupported.HasValue)
       {
     this.m_FormatSupported = new bool?(true);
     foreach (Object target in this.targets)
     {
       TrueTypeFontImporter typeFontImporter = target as TrueTypeFontImporter;
       if ((Object) typeFontImporter == (Object) null || !typeFontImporter.IsFormatSupported())
     this.m_FormatSupported = new bool?(false);
     }
       }
       bool? formatSupported = this.m_FormatSupported;
       if ((formatSupported.GetValueOrDefault() ? 0 : (formatSupported.HasValue ? 1 : 0)) != 0)
       {
     this.ShowFormatUnsupportedGUI();
       }
       else
       {
     EditorGUILayout.PropertyField(this.m_FontSize);
     if (this.m_FontSize.intValue < 1)
       this.m_FontSize.intValue = 1;
     if (this.m_FontSize.intValue > 500)
       this.m_FontSize.intValue = 500;
     EditorGUILayout.IntPopup(this.m_FontRenderingMode, TrueTypeFontImporterInspector.kRenderingModeStrings, TrueTypeFontImporterInspector.kRenderingModeValues, new GUIContent("Rendering Mode"), new GUILayoutOption[0]);
     EditorGUILayout.IntPopup(this.m_TextureCase, TrueTypeFontImporterInspector.kCharacterStrings, TrueTypeFontImporterInspector.kCharacterValues, new GUIContent("Character"), new GUILayoutOption[0]);
     EditorGUILayout.IntPopup(this.m_AscentCalculationMode, TrueTypeFontImporterInspector.kAscentCalculationModeStrings, TrueTypeFontImporterInspector.kAscentCalculationModeValues, new GUIContent("Ascent Calculation Mode"), new GUILayoutOption[0]);
     if (!this.m_TextureCase.hasMultipleDifferentValues)
     {
       if (this.m_TextureCase.intValue != -2)
       {
     if (this.m_TextureCase.intValue == 3)
     {
       EditorGUI.BeginChangeCheck();
       GUILayout.BeginHorizontal();
       EditorGUILayout.PrefixLabel("Custom Chars");
       EditorGUI.showMixedValue = this.m_CustomCharacters.hasMultipleDifferentValues;
       string source = EditorGUILayout.TextArea(this.m_CustomCharacters.stringValue, GUI.skin.textArea, GUILayout.MinHeight(32f));
       EditorGUI.showMixedValue = false;
       GUILayout.EndHorizontal();
       if (EditorGUI.EndChangeCheck())
         this.m_CustomCharacters.stringValue = new string(source.Distinct<char>().ToArray<char>()).Replace("\n", string.Empty).Replace("\r", string.Empty);
     }
       }
       else
       {
     EditorGUILayout.PropertyField(this.m_IncludeFontData, new GUIContent("Incl. Font Data"), new GUILayoutOption[0]);
     if (this.targets.Length == 1)
     {
       EditorGUI.BeginChangeCheck();
       GUILayout.BeginHorizontal();
       EditorGUILayout.PrefixLabel("Font Names");
       GUI.SetNextControlName("fontnames");
       this.m_FontNamesString = EditorGUILayout.TextArea(this.m_FontNamesString, (GUIStyle) "TextArea", GUILayout.MinHeight(32f));
       GUILayout.EndHorizontal();
       GUILayout.BeginHorizontal();
       GUILayout.FlexibleSpace();
       EditorGUI.BeginDisabledGroup(this.m_FontNamesString == this.m_DefaultFontNamesString);
       if (GUILayout.Button("Reset", (GUIStyle) "MiniButton", new GUILayoutOption[0]))
       {
         GUI.changed = true;
         if (GUI.GetNameOfFocusedControl() == "fontnames")
           GUIUtility.keyboardControl = 0;
         this.m_FontNamesString = this.m_DefaultFontNamesString;
       }
       EditorGUI.EndDisabledGroup();
       GUILayout.EndHorizontal();
       if (EditorGUI.EndChangeCheck())
         this.SetFontNames(this.m_FontNamesString);
       this.m_ReferencesExpanded = EditorGUILayout.Foldout(this.m_ReferencesExpanded, "References to other fonts in project");
       if (this.m_ReferencesExpanded)
       {
         EditorGUILayout.HelpBox("These are automatically generated by the inspector if any of the font names you supplied match fonts present in your project, which will then be used as fallbacks for this font.", MessageType.Info);
         if (this.m_FallbackFontReferencesArraySize.intValue > 0)
         {
           SerializedProperty property = this.m_FallbackFontReferencesArraySize.Copy();
           while (property.NextVisible(true) && property.depth == 1)
             EditorGUILayout.PropertyField(property, true, new GUILayoutOption[0]);
         }
         else
         {
           EditorGUI.BeginDisabledGroup(true);
           GUILayout.Label("No references to other fonts in project.");
           EditorGUI.EndDisabledGroup();
         }
       }
     }
       }
     }
     this.ApplyRevertGUI();
       }
 }
示例#18
0
        void DrawControls()
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_AnimatorProperty, m_AnimatorLabel);
            if (EditorGUI.EndChangeCheck())
            {
                m_AnimSync.ResetParameterOptions();
            }

            if (m_AnimSync.animator == null)
            {
                return;
            }

            var controller = m_AnimSync.animator.runtimeAnimatorController as AnimatorController;

            if (controller != null)
            {
                var showWarning = false;
                EditorGUI.indentLevel += 1;
                int i = 0;

                foreach (var p in controller.parameters)
                {
                    if (i >= 32)
                    {
                        showWarning = true;
                        break;
                    }

                    bool oldSend = m_AnimSync.GetParameterAutoSend(i);
                    bool send    = EditorGUILayout.Toggle(p.name, oldSend);
                    if (send != oldSend)
                    {
                        m_AnimSync.SetParameterAutoSend(i, send);
                        EditorUtility.SetDirty(target);
                    }
                    i += 1;
                }

                if (showWarning)
                {
                    EditorGUILayout.HelpBox("NetworkAnimator can only select between the first 32 parameters in a mecanim controller", MessageType.Warning);
                }

                EditorGUI.indentLevel -= 1;
            }

            if (Application.isPlaying)
            {
                EditorGUILayout.Separator();
                if (m_AnimSync.param0 != "")
                {
                    EditorGUILayout.LabelField("Param 0", m_AnimSync.param0);
                }
                if (m_AnimSync.param1 != "")
                {
                    EditorGUILayout.LabelField("Param 1", m_AnimSync.param1);
                }
                if (m_AnimSync.param2 != "")
                {
                    EditorGUILayout.LabelField("Param 2", m_AnimSync.param2);
                }
                if (m_AnimSync.param3 != "")
                {
                    EditorGUILayout.LabelField("Param 3", m_AnimSync.param3);
                }
                if (m_AnimSync.param4 != "")
                {
                    EditorGUILayout.LabelField("Param 4", m_AnimSync.param4);
                }
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            // Remove Settings are taken from preferences and NOT from the EditorSettings Asset.
            // Only show them when editing the "global" settings
            if (m_IsGlobalSettings)
            {
                ShowUnityRemoteGUI(editorEnabled);
            }

            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            GUILayout.Space(10);

            int index = m_SerializationMode.intValue;

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;
                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            if (m_SerializationMode.intValue != (int)SerializationMode.ForceBinary)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_SerializeInlineMappingsOnOneLine);
                if (EditorGUI.EndChangeCheck() && m_IsGlobalSettings)
                {
                    EditorSettings.serializeInlineMappingsOnOneLine = m_SerializeInlineMappingsOnOneLine.boolValue;
                }
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp(m_DefaultBehaviorMode.intValue, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            // CacheServer is part asset and preferences. Only show UI in case of Global Settings editing.
            if (m_IsGlobalSettings)
            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                var scene = m_PrefabRegularEnvironment.objectReferenceValue as SceneAsset;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    m_PrefabRegularEnvironment.objectReferenceValue = scene;
                    if (m_IsGlobalSettings)
                    {
                        EditorSettings.prefabRegularEnvironment = scene;
                    }
                }
            }
            {
                EditorGUI.BeginChangeCheck();
                var scene = m_PrefabUIEnvironment.objectReferenceValue as SceneAsset;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    m_PrefabUIEnvironment.objectReferenceValue = scene;
                    if (m_IsGlobalSettings)
                    {
                        EditorSettings.prefabUIEnvironment = scene;
                    }
                }
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            if (m_IsGlobalSettings)
            {
                EditorGUI.BeginChangeCheck();
                bool showRes = LightmapVisualization.showResolution;
                showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
                if (EditorGUI.EndChangeCheck())
                {
                    LightmapVisualization.showResolution = showRes;
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_UseLegacyProbeSampleCount, Content.useLegacyProbeSampleCount);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_IsGlobalSettings)
                {
                    EditorSettings.useLegacyProbeSampleCount = m_UseLegacyProbeSampleCount.boolValue;
                }

                EditorApplication.RequestRepaintAllViews();
            }

            var rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, Content.enableCookiesInLightmapper, m_DisableCookiesInLightmapper);
            EditorGUI.BeginChangeCheck();
            bool enableCookiesInLightmapperValue = !m_DisableCookiesInLightmapper.boolValue;

            enableCookiesInLightmapperValue = EditorGUI.Toggle(rect, Content.enableCookiesInLightmapper, enableCookiesInLightmapperValue);
            if (EditorGUI.EndChangeCheck())
            {
                m_DisableCookiesInLightmapper.boolValue = !enableCookiesInLightmapperValue;

                if (m_IsGlobalSettings)
                {
                    EditorSettings.enableCookiesInLightmapper = enableCookiesInLightmapperValue;
                }

                EditorApplication.RequestRepaintAllViews();
            }
            EditorGUI.EndProperty();

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            // Legacy Packer has been deprecated.
            index = Mathf.Clamp(m_SpritePackerMode.intValue - spritePackDeprecatedEnums, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (m_SpritePackerMode.intValue == (int)SpritePackerMode.SpriteAtlasV2)
            {
                var message = "Sprite Atlas V2 (Experimental) supports CacheServer with Importer workflow. Please take a backup of your project before switching to V2.";
                EditorGUILayout.HelpBox(message, MessageType.Info, true);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
        }
示例#20
0
    private void OnPlaneGenerationGUI()
    {
        planeGenerationData = planeGenerationData ?? new PlaneGenerationData();

        planeGenerationData.direction = (PlaneGenerationData.Direction)UG.EnumPopup("平面方向", planeGenerationData.direction);

        UG.BeginHorizontal();

        planeGenerationData.length = UG.DelayedFloatField("长", planeGenerationData.length);
        planeGenerationData.width  = UG.DelayedFloatField("宽", planeGenerationData.width);

        UG.EndHorizontal();

        UG.BeginHorizontal();

        planeGenerationData.verticesPerLength = UG.DelayedIntField("长顶点数", planeGenerationData.verticesPerLength);
        planeGenerationData.verticesPerWidth  = UG.DelayedIntField("宽顶点数", planeGenerationData.verticesPerWidth);

        UG.EndHorizontal();

        bool   legal        = true;
        string errorMessage = String.Empty;

        if (defaultMaterial == null)
        {
            legal         = false;
            errorMessage += "默认材质不能为空";
        }

        if (planeGenerationData.length <= 0)
        {
            legal         = false;
            errorMessage += "平面长必须大于0\n";
        }

        if (planeGenerationData.width <= 0)
        {
            legal         = false;
            errorMessage += "平面宽必须大于0\n";
        }

        if (planeGenerationData.verticesPerLength <= 0)
        {
            legal         = false;
            errorMessage += "平面长顶点数必须大于0\n";
        }

        if (planeGenerationData.verticesPerWidth <= 0)
        {
            legal         = false;
            errorMessage += "平面宽顶点数必须大于0\n";
        }

        if (legal)
        {
            if (GUILayout.Button("生成"))
            {
                MeshTool.InstantiatePlane(planeGenerationData, defaultMaterial);
            }
        }
        else
        {
            UG.HelpBox(errorMessage, MessageType.Error);
        }
    }
示例#21
0
        public override void OnInspectorGUI()
        {
            transition = (Transition)target;

            EditorGUI.BeginChangeCheck();

            var fromName    = transition.fromState.GetStatePreview();
            var toName      = transition.targetInfo;
            var displayName = fromName + "->" + toName;

            EGL.LabelField(displayName);
            EGL.Space();

            FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect);
            EGL.Space();

            transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType);

            if (transition.triggerRangeType == TriggerRangeType.Range)
            {
                transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange);
            }
            if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore)
            {
                transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec);
            }

            transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer);

            using (new EGL.VerticalScope(EditorStyles.helpBox))  {
                var conds      = transition.conditions;
                var paramNames = transition.profile.parameters.Select(it => it.name).ToArray();

                using (new EGL.HorizontalScope()) {
                    EGL.LabelField("Conditions", EditorStyles.boldLabel);
                    GL.FlexibleSpace();
                    if (GL.Button("+", GL.Width(30)))
                    {
                        conds.Add(new Condition());
                    }
                }
                for (int i = 0; i < conds.Count; ++i)
                {
                    var cond = conds[i];

                    EGL.BeginHorizontal();

                    int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name));

                    // cond.name = EGL.TextField(cond.name, GL.Width(70));
                    condSelectIndex = EGL.Popup(condSelectIndex, paramNames);
                    cond.name       = paramNames[condSelectIndex];

                    var param = transition.profile.FindParam(cond.name);
                    if (param == null)
                    {
                        EGL.LabelField("!Doesn't exist");
                    }
                    else
                    {
                        var type = param.type;
                        if (type == ParamType.Bool)
                        {
                            cond.boolValue = EGL.Toggle(cond.boolValue);
                        }
                        else if (type != ParamType.Trigger) // Trigger 不需要编辑
                        {
                            cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50));

                            if (type == ParamType.Int)
                            {
                                cond.intValue = EGL.IntField(cond.intValue);
                            }
                            else
                            {
                                cond.floatValue = EGL.FloatField(cond.floatValue);
                            }
                        }
                    }

                    GL.FlexibleSpace();
                    if (GL.Button("-", GL.Width(30)))
                    {
                        conds.RemoveAt(i);
                        --i;
                    }

                    EGL.EndHorizontal();
                }
            }

            EGL.LabelField("", GUI.skin.horizontalSlider);

            transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType);

            if (transition.actionType == ActionType.ChangeState)
            {
                EGL.BeginHorizontal();
                EGL.PrefixLabel("Target State");
                EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames,
                                               str => transition.targetStateName = str, ref targetStateRect);

                transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30));
                EGL.LabelField("F", GUILayout.Width(20));

                var targetState = transition.profile.FindState(transition.targetStateName);
                if (targetState)
                {
                    if (GL.Button("Focus"))
                    {
                        Utils.FocusEditingAnimation(transition.profile, targetState.stateName);
                    }
                }
                EGL.EndHorizontal();

                if (!targetState)
                {
                    EGL.HelpBox("No target state " + targetState, MessageType.Error);
                }
            }
            else // SendMessage
            {
                transition.messageName = EGL.TextField("Message Name", transition.messageName);

                EGL.Space();
                transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType);

                switch (transition.messageParType)
                {
                case MessageParType.Int:
                    transition.messageParInt = EGL.IntField("Value", transition.messageParInt);
                    break;

                case MessageParType.Float:
                    transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat);
                    break;

                case MessageParType.Bool:
                    transition.messageParBool = EGL.Toggle("Value", transition.messageParBool);
                    break;
                }
            }

            transition.priority    = EGL.IntField("Priority", transition.priority);
            transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay);
            if (transition.shouldDelay)
            {
                transition.delay = EGL.FloatField("Delay", transition.delay);
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(transition);
            }

            if (transition.fromState.type == FromStateType.State)
            {
                EGL.LabelField("", GUI.skin.horizontalSlider);
                using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                    EGL.LabelField("From State", EditorStyles.boldLabel);
                    ++EditorGUI.indentLevel;
                    var fromState = transition.profile.FindState(transition.fromState.stateOrTagName);
                    if (fromState)
                    {
                        GUI.enabled = false;
                        if (!fromStateEditor || fromStateEditor.target != fromState)
                        {
                            if (fromStateEditor)
                            {
                                DestroyImmediate(fromStateEditor);
                            }
                            fromStateEditor = Editor.CreateEditor(fromState);
                        }

                        fromStateEditor.OnInspectorGUI();
                        GUI.enabled = true;
                    }
                    --EditorGUI.indentLevel;
                }
            }
        }
示例#22
0
            internal void RenderLightProbeUsage(int selectionCount, Renderer renderer, bool useMiniStyle, bool lightProbeAllowed)
            {
                using (new EditorGUI.DisabledScope(!lightProbeAllowed))
                {
                    if (lightProbeAllowed)
                    {
                        // LightProbeUsage has non-sequential enum values. Extra care is to be taken.
                        if (useMiniStyle)
                        {
                            EditorGUI.BeginChangeCheck();
                            var newValue = ModuleUI.GUIEnumPopup(m_LightProbeUsageStyle, (LightProbeUsage)m_LightProbeUsage.intValue, m_LightProbeUsage);
                            if (EditorGUI.EndChangeCheck())
                            {
                                m_LightProbeUsage.intValue = (int)(LightProbeUsage)newValue;
                            }
                        }
                        else
                        {
                            Rect r = EditorGUILayout.GetControlRect(true, EditorGUI.kSingleLineHeight, EditorStyles.popup);
                            EditorGUI.BeginProperty(r, m_LightProbeUsageStyle, m_LightProbeUsage);
                            EditorGUI.BeginChangeCheck();
                            var newValue = EditorGUI.EnumPopup(r, m_LightProbeUsageStyle, (LightProbeUsage)m_LightProbeUsage.intValue);
                            if (EditorGUI.EndChangeCheck())
                            {
                                m_LightProbeUsage.intValue = (int)(LightProbeUsage)newValue;
                            }
                            EditorGUI.EndProperty();
                        }

                        if (!m_LightProbeUsage.hasMultipleDifferentValues)
                        {
                            if (m_LightProbeUsage.intValue == (int)LightProbeUsage.UseProxyVolume &&
                                SupportedRenderingFeatures.active.lightProbeProxyVolumes)
                            {
                                EditorGUI.indentLevel++;
                                if (useMiniStyle)
                                {
                                    ModuleUI.GUIObject(m_LightProbeVolumeOverrideStyle, m_LightProbeVolumeOverride);
                                }
                                else
                                {
                                    EditorGUILayout.PropertyField(m_LightProbeVolumeOverride, m_LightProbeVolumeOverrideStyle);
                                }
                                EditorGUI.indentLevel--;
                            }
                            else if (m_LightProbeUsage.intValue == (int)LightProbeUsage.CustomProvided)
                            {
                                EditorGUI.indentLevel++;
                                if (!Application.isPlaying)
                                {
                                    EditorGUILayout.HelpBox(m_LightProbeCustomNote.text, MessageType.Info);
                                }
                                else if (!renderer.HasPropertyBlock())
                                {
                                    EditorGUILayout.HelpBox(m_LightProbeCustomNote.text, MessageType.Error);
                                }
                                EditorGUI.indentLevel--;
                            }
                        }
                    }
                    else
                    {
                        if (useMiniStyle)
                        {
                            ModuleUI.GUIEnumPopup(m_LightProbeUsageStyle, LightProbeUsage.Off, m_LightProbeUsage);
                        }
                        else
                        {
                            EditorGUILayout.EnumPopup(m_LightProbeUsageStyle, LightProbeUsage.Off);
                        }
                    }
                }

                Tree tree;

                renderer.TryGetComponent(out tree);
                if ((tree != null) && (m_LightProbeUsage.intValue == (int)LightProbeUsage.UseProxyVolume))
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.HelpBox(m_LightProbeVolumeUnsupportedOnTreesNote.text, MessageType.Warning);
                    EditorGUI.indentLevel--;
                }
            }
示例#23
0
 private void ShowFormatUnsupportedGUI()
 {
     GUILayout.Space(5f);
       EditorGUILayout.HelpBox("Format of selected font is not supported by Unity.", MessageType.Warning);
 }
示例#24
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfRequiredOrScript();

            Label("General", EditorStyles.boldLabel);
            E.PropertyField(serializedObject.FindProperty(nameof(VT0Info.ThumbSize)));
            E.PropertyField(serializedObject.FindProperty(nameof(VT0Info.MemoryCompression)));

            var    vramBytes = ((VT0Info)target).EstimateVRAM(100);
            string specifier = "B";

            if (vramBytes > (1 << 30))
            {
                vramBytes /= (1 << 30);
                specifier  = "GiB";
            }
            else if (vramBytes > (1 << 20))
            {
                vramBytes /= (1 << 20);
                specifier  = "MiB";
            }
            else if (vramBytes > (1 << 10))
            {
                vramBytes /= (1 << 10);
                specifier  = "KiB";
            }

            E.HelpBox(
                $"This configuration uses approximately {vramBytes:F1} {specifier} of VRAM",
                MessageType.Info);

            BeginHorizontal();
            if (serializedObject.FindProperty(nameof(VT0Info.Modified)).boolValue)
            {
                GUI.color = Color.red;
                E.HelpBox("Settings were modified; apply changes before running", MessageType.None);
                GUI.color = Color.white;
            }
            else
            {
                E.HelpBox("No modifications", MessageType.None);
            }
            if (Button("Apply", ExpandWidth(false)))
            {
                UpdateChannelFile();
                serializedObject.FindProperty(nameof(VT0Info.Modified)).boolValue = false;
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
            EndHorizontal();

            var channels = serializedObject.FindProperty(nameof(VT0Info.Channels));

            for (int j = 0; j < channels.arraySize; j++)
            {
                var channel = channels.GetArrayElementAtIndex(j);
                BeginVertical("HelpBox");
                BeginHorizontal();
                Label("Channel", EditorStyles.boldLabel);
                var removeChannel = Button("x", Width(20f));
                EndHorizontal();

                E.PropertyField(channel.FindPropertyRelative(nameof(VT0Channel.Count)));

                BeginHorizontal();
                Label("Format");
                var format = channel.FindPropertyRelative(nameof(VT0Channel.Format));
                E.PropertyField(format, GUIContent.none, MaxWidth(120f));
                // TODO: Platform-specific formats
                if (Button("Opaque"))
                {
                    format.intValue = (int)TextureFormat.DXT1;
                }
                if (Button("Transparent"))
                {
                    format.intValue = (int)TextureFormat.DXT5;
                }
                if (Button("Alpha"))
                {
                    format.intValue = (int)TextureFormat.Alpha8;
                }
                EndHorizontal();

                var textureNames = channel.FindPropertyRelative(nameof(VT0Channel.TextureNames));
                BeginHorizontal();
                if (Button("+", Width(20f)))
                {
                    textureNames.arraySize++;
                }
                Label("Property names:", EditorStyles.miniLabel);
                EndHorizontal();

                for (int i = 0; i < textureNames.arraySize; i++)
                {
                    BeginHorizontal();
                    var removeMe = Button("x", Width(20f));
                    E.PropertyField(textureNames.GetArrayElementAtIndex(i), GUIContent.none);
                    EndHorizontal();
                    if (removeMe)
                    {
                        textureNames.DeleteArrayElementAtIndex(i--);
                    }
                }

                E.Space();
                EndVertical();

                if (removeChannel)
                {
                    channels.DeleteArrayElementAtIndex(j--);
                }
            }

            BeginHorizontal();
            FlexibleSpace();
            if (Button("New channel"))
            {
                channels.arraySize++;
            }
            FlexibleSpace();
            EndHorizontal();

            if (serializedObject.ApplyModifiedProperties())
            {
                serializedObject.FindProperty(nameof(VT0Info.Modified)).boolValue = true;
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
        }
示例#25
0
        private void OnGUI()
        {
            if (settings == null)
            {
                settings = ConstantGenerator.GetSettingsFile();
            }

            if (logo == null)
            {
                logo = ConstantGenerator.GetLogo();
            }

            if (border == null)
            {
                border = ConstantGenerator.GetBorder();
            }

            EditorGUI.BeginChangeCheck();

            StartGUI("Layers");
            if (DrawGenButton())
            {
                LayersGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                LayersGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Tags");
            if (DrawGenButton())
            {
                TagsGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                TagsGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Sort Layers");
            if (DrawGenButton())
            {
                SortingLayersGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                SortingLayersGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Scenes");
            if (DrawGenButton())
            {
                ScenesGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                ScenesGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Shader Props");
            if (DrawGenButton())
            {
                ShaderPropsGen.Generate(false);
                window.Close();
            }

            if (DrawForceGenButton())
            {
                ShaderPropsGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Anim Params");
            if (DrawGenButton())
            {
                AnimParamsGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                AnimParamsGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Anim Layers");
            if (DrawGenButton())
            {
                AnimLayersGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                AnimLayersGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Anim States");
            if (DrawGenButton())
            {
                AnimStatesGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                AnimStatesGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Nav Areas");
            if (DrawGenButton())
            {
                NavAreasGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                NavAreasGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // =========================================================================================
            DrawLine(Color.white, 2, 5);

            GUIStyle style = new GUIStyle(GUI.skin.button);

            style.alignment = TextAnchor.MiddleCenter;
            style.fontStyle = FontStyle.Bold;

            EGL.BeginHorizontal();
            EGL.BeginVertical();
            EGL.BeginHorizontal();
            if (GL.Button("GENERATE ALL", style))
            {
                LayersGen.Generate();
                TagsGen.Generate();
                SortingLayersGen.Generate();
                ScenesGen.Generate();
                ShaderPropsGen.Generate(false);
                AnimParamsGen.Generate();
                AnimLayersGen.Generate();
                AnimStatesGen.Generate();
                window.Close();
            }
            GL.FlexibleSpace();
            EGL.EndHorizontal();

            EGL.BeginHorizontal();
            if (GL.Button("FORCE GENERATE ALL", style))
            {
                LayersGen.ForceGenerate();
                TagsGen.ForceGenerate();
                SortingLayersGen.ForceGenerate();
                ScenesGen.ForceGenerate();
                ShaderPropsGen.ForceGenerate();
                AnimParamsGen.ForceGenerate();
                AnimLayersGen.ForceGenerate();
                AnimStatesGen.ForceGenerate();
                window.Close();
            }
            GL.FlexibleSpace();
            EGL.EndHorizontal();
            EGL.EndVertical();
            EGL.BeginVertical();
            // ---------------------------------------------------------------------------------------
            Color genOnReloadColor;
            Color updateOnReloadColor;

            if (settings.regenerateOnMissing)
            {
                genOnReloadColor = Color.green * 2;
            }
            else
            {
                genOnReloadColor = Color.white * 1.5f;
            }

            if (settings.updateOnReload)
            {
                updateOnReloadColor = Color.green * 2;
            }
            else
            {
                updateOnReloadColor = Color.white * 1.5f;
            }

            EGL.BeginHorizontal();
            GUI.backgroundColor = genOnReloadColor;
            if (GL.Button(new GUIContent("ReGen On Missing", "Automatically re-generates the constants file is none is present."), style))
            {
                settings.regenerateOnMissing = !settings.regenerateOnMissing;
                EditorUtility.SetDirty(settings);
            }
            EGL.EndHorizontal();

            EGL.BeginHorizontal();
            GUI.backgroundColor = updateOnReloadColor;
            if (GL.Button(new GUIContent("Update On Reload", "Automatically re-generates the constants on editor recompile if any changes are detected."), style))
            {
                settings.updateOnReload = !settings.updateOnReload;
                EditorUtility.SetDirty(settings);
            }
            EGL.EndHorizontal();

            EGL.EndVertical();
            EGL.EndHorizontal();
            // =========================================================================================
            DrawLine(Color.white, 2, 5);

            GUI.backgroundColor = Color.gray;
            GUI.contentColor    = Color.white * 10;

// check for unity versions using conditional directives
// NOTE: there is no "BeginFoldoutHeaderGroup" in below 2019.1
 #if UNITY_2019_OR_NEWER
            showFoldOut = EGL.BeginFoldoutHeaderGroup(showFoldOut, "Create Generator Script");
#else
            showFoldOut = EGL.Foldout(showFoldOut, "Create Generator Script");
 #endif
            if (showFoldOut)
            {
                GL.Space(5);
                GUI.contentColor = Color.white * 10;
                generatorName    = EGL.TextField("Generator Name", generatorName);
                outputFileName   = EGL.TextField("Output File Name", outputFileName);

                GL.Space(5);
                EGL.BeginHorizontal();

                if (!settings.regenerateOnMissing)
                {
                    EGL.BeginVertical();
                    GL.FlexibleSpace();
                    EGL.HelpBox("NOTE: Force Generate will only delete the file but will NOT generate a new one if the [ReGen On Missing] is turned off",
                                MessageType.Warning);
                    EGL.EndVertical();
                }
                else
                {       // ============================================================================
                        // Draw Ma Awesome Logo
                    EGL.BeginVertical();
                    GL.FlexibleSpace();
                    Rect horiRect = EGL.BeginHorizontal();

                    Rect boxRect = new Rect(horiRect.x + 3, horiRect.y - 54, 125, 52);

                    Rect backgroundRect = boxRect;
                    backgroundRect.width  = border.width;
                    backgroundRect.height = border.height;
                    GUI.DrawTexture(backgroundRect, border);
                    // GUI.Box( boxRect, iconBackground, );

                    GUI.Label(new Rect(boxRect.x + 3, boxRect.y + 16, 100, 20), "Created BY: ");

                    Rect logoRect = new Rect(boxRect.x + 76, boxRect.y + 2, logo.width, logo.height);
                    GUI.DrawTexture(logoRect, logo);

                    EGL.EndHorizontal();
                    EGL.EndVertical();
                    // ============================================================================
                }

                GL.FlexibleSpace();

                GUI.contentColor = Color.white * 5;
                EGL.BeginVertical();
                GL.FlexibleSpace();
                GUI.backgroundColor = Color.white * 2.5f;
                GUI.contentColor    = Color.black * 5;
                if (GL.Button("Create", new GUIStyle(GUI.skin.button)
                {
                    fontStyle = FontStyle.Bold, fontSize = 12
                },
                              GL.Width(75), GL.Height(30)))
                {
                    if (generatorName == string.Empty || outputFileName == string.Empty || generatorName == null || outputFileName == null)
                    {
                        Debug.LogWarning("Fill out all the fields");
                    }
                    else
                    {
                        TemplateGen.GenerateTemplate(generatorName, outputFileName);
                        window.Close();
                    }
                }
                EGL.EndVertical();
                GL.Space(1);
                EGL.EndHorizontal();
            }

 #if UNITY_2019_OR_NEWER
            EGL.EndFoldoutHeaderGroup();
 #endif

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(settings);
            }
        }
示例#26
0
    private void OnGUI()
    {
        UG.BeginVertical();

        UG.BeginHorizontal();
        UG.LabelField("当前数据源:" + (_dataPath.IsNullPath() ? "未在本地保存,已编辑内容随时可能丢失!" : _dataPath));
        if (GUILayout.Button("选择"))
        {
            string path = EditorUtility.OpenFilePanelWithFilters("选择数据源文件", Application.dataPath + "/Hotassets/Data", new [] { "text", "txt" });
            if (!string.IsNullOrEmpty(path))
            {
                Dictionary <string, List <InterlocutionData> > temperData = null;
                try {
                    temperData = JsonConvert.DeserializeObject <Dictionary <string, List <InterlocutionData> > >(File.ReadAllText(path));
                } catch (JsonException) {
                    temperData = _data;
                    path       = _dataPath;
                    EditorApplication.Beep();
                    EditorUtility.DisplayDialog("异常捕获!", "数据源文件不能被正确加载,请确定.json文件的有效性", "知道了");
                } finally {
                    _data     = temperData;
                    _dataPath = path;
                }
            }
        }

        UG.EndHorizontal();

        UG.BeginHorizontal();

        int subject = UG.Popup("所属学科", _editingSubject, InterlocutionData.Keys);

        if (subject != _editingSubject)
        {
            _editingInterlocution = -1;
        }
        _editingSubject = subject;
        string key = InterlocutionData.Keys[_editingSubject];

        UG.LabelField("分组", _editingSubject != InterlocutionData.Keys.Length - 1 ? Subject.ToSubject(InterlocutionData.Keys[_editingSubject]).group.ToString() : "无");

        UG.EndHorizontal();

        _scrollPostion = UG.BeginScrollView(_scrollPostion);

        if (!_data.ContainsKey(key))
        {
            _data[key] = new List <InterlocutionData>();
        }
        List <InterlocutionData> interlocutions = _data[key];

        int _deletedInterlocution = -1;

        UG.LabelField("[已有 " + interlocutions.Count + " 道问答]");
        for (int i = 0, l = interlocutions.Count; i < l; i++)
        {
            UG.BeginHorizontal();

            UG.LabelField("[Q " + i + "] " + interlocutions[i].question);
            if (GUILayout.Button("编辑"))
            {
                _editingInterlocution = i;
            }

            if (GUILayout.Button("删除"))
            {
                EditorApplication.Beep();
                if (EditorUtility.DisplayDialog("危险操作警告⚠️", "即将删除问答 [Q" + i + "] (该操作不可逆)", "确认", "取消"))
                {
                    _deletedInterlocution = i;
                    if (_editingInterlocution == _deletedInterlocution)
                    {
                        _editingInterlocution = -1;
                    }
                }
            }

            UG.EndHorizontal();
        }

        if (_deletedInterlocution != -1)
        {
            interlocutions.RemoveAt(_deletedInterlocution);
        }

        UG.EndScrollView();

        if (GUILayout.Button("添加问答"))
        {
            _editingInterlocution = interlocutions.Count;
            interlocutions.Add(new InterlocutionData());
        }

        UG.LabelField("问答编辑区");
        if (_editingInterlocution != -1)
        {
            UG.LabelField("Q " + _editingInterlocution);
            InterlocutionData interlocution = interlocutions[_editingInterlocution];
            interlocution.question = UG.TextArea(interlocution.question);
            interlocution.answer   = (Option)UG.EnumPopup("正确选项", interlocution.answer);
            UG.LabelField("选项A");
            interlocution.optionA = UG.TextArea(interlocution.optionA);
            UG.LabelField("选项B");
            interlocution.optionB = UG.TextArea(interlocution.optionB);
            UG.LabelField("选项C");
            interlocution.optionC = UG.TextArea(interlocution.optionC);
            UG.LabelField("选项D");
            interlocution.optionD = UG.TextArea(interlocution.optionD);
        }
        else
        {
            UG.HelpBox("需要选择一个问答进行编辑!", MessageType.Warning);
        }

        if (GUILayout.Button("保存"))
        {
            bool toSave   = true;
            bool toImport = false;
            if (_dataPath.IsNullPath())
            {
                string path = EditorUtility.SaveFilePanel("保存问答数据", Application.dataPath + "/Hotassets/Data", "InterlocutionData", "txt");
                if (string.IsNullOrEmpty(path))
                {
                    toSave = false;
                }
                else
                {
                    _dataPath = path;
                    toImport  = true;
                }
            }

            if (toSave)
            {
                File.WriteAllText(_dataPath, JsonConvert.SerializeObject(_data));
                EditorPrefs.SetString(DATA_SAVE_PATH, _dataPath);
            }

            if (toImport)
            {
                AssetDatabase.ImportAsset(_dataPath.Substring(_dataPath.IndexOf("Assets")));
            }
        }

        UG.EndVertical();
    }
示例#27
0
    void showRoadMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated && growthMapGenerated && populationGenerated));
        showRoadMapUI = EGL.Foldout(showRoadMapUI, roadmapLabel, true);
        if (showRoadMapUI)
        {
            GL.Label("Streets", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label("Width");
            GL.Label("Min Length");
            GL.Label("LookAhead");
            GL.Label("Pop Threshold");
            GL.Label("Max Slope");
            GL.EndVertical();
            GL.BeginVertical();
            CG.streetWidth        = EGL.IntSlider(CG.streetWidth, 5, 20);
            CG.streetMinLength    = EGL.Slider(CG.streetMinLength, 5f, 100f);
            CG.streetLookAhead    = EGL.IntSlider(CG.streetLookAhead, 1, (int)(CG.terrainSize / CG.streetMinLength));
            CG.streetPopThreshold = EGL.Slider(CG.streetPopThreshold, 0f, 1f);
            CG.streetMaxSlope     = EGL.Slider(CG.streetMaxSlope, 0f, 1f);
            GL.EndVertical();
            GL.EndHorizontal();

            GL.Space(5);

            GL.Label("Highways", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label("Width");
            GL.Label("Min Length");
            GL.Label("LookAhead");
            GL.Label("Pop Threshold");
            GL.Label("Max Slope");
            GL.EndVertical();
            GL.BeginVertical();
            CG.highwayWidth        = EGL.IntSlider(CG.highwayWidth, 10, 25);
            CG.highwayMinLength    = EGL.Slider(CG.highwayMinLength, 5f, 200f);
            CG.highwayLookAhead    = EGL.IntSlider(CG.highwayLookAhead, 1, (int)(CG.terrainSize / CG.highwayMinLength));
            CG.highwayPopThreshold = EGL.Slider(CG.highwayPopThreshold, 0f, 1f);
            CG.highwayMaxSlope     = EGL.Slider(CG.highwayMaxSlope, 0f, 1f);
            GL.EndVertical();
            GL.EndHorizontal();

            GL.Space(10);

            showRoadMapAdvanced = EGL.Foldout(showRoadMapAdvanced, "Advanced Settings", true);
            if (showRoadMapAdvanced)
            {
                EGL.HelpBox("Adjusting these settings might break the Editor or severely influence performance.", MessageType.Warning);
                GL.Label("General Advanced Settings", EditorStyles.centeredGreyMiniLabel);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Legalization Attempts");
                GL.Label("Min Road Correction Angle");
                GL.Label("Node Check Radius");
                GL.Label("Road Connect Max Distance");
                GL.Label("Ray Count");
                GL.EndVertical();
                GL.BeginVertical();
                CG.legalizationAttempts = EGL.IntSlider(CG.legalizationAttempts, 1, 100);
                CG.minRoadAngle         = EGL.IntSlider(CG.minRoadAngle, 0, 90);
                CG.nodeCheckRadius      = EGL.Slider(CG.nodeCheckRadius, 0f, 100f);
                CG.roadConnectDistance  = EGL.Slider(CG.roadConnectDistance, 0f, 100f);
                CG.rayCount             = EGL.IntSlider(CG.rayCount, 1, 32);
                GL.EndVertical();
                GL.EndHorizontal();

                GL.Label("Advanced Settings for L-system Component", EditorStyles.centeredGreyMiniLabel);
                EGL.HelpBox("Low values correspond to higher priority.", MessageType.Info);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Street - Priority");
                GL.Label("Highway - Priority");
                GL.EndVertical();
                GL.BeginVertical();
                CG.streetPriority  = EGL.IntSlider(CG.streetPriority, 1, 5);
                CG.highwayPriority = EGL.IntSlider(CG.highwayPriority, 1, 5);
                GL.EndVertical();
                GL.EndHorizontal();

                GL.Label("Advanced Settings for Growth Rules", EditorStyles.centeredGreyMiniLabel);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Street - Straight Angle");
                GL.Label("Street - Branch  Angle");
                GL.Space(10);
                GL.Label("Highway - Branch Prob");
                GL.Label("Highway - Straight Angle");
                GL.Label("Highway - Branch Angle");
                GL.EndVertical();
                GL.BeginVertical();
                CG.streetStraightAngle = EGL.Slider(CG.streetStraightAngle, 0f, 90f);
                CG.streetBranchAngle   = EGL.Slider(CG.streetBranchAngle, 0f, 90f);
                GL.Space(10);
                CG.highwayBranchProb    = EGL.Slider(CG.highwayBranchProb, 0f, 1f);
                CG.highwayStraightAngle = EGL.Slider(CG.highwayStraightAngle, 0f, 90f);
                CG.highwayBranchAngle   = EGL.Slider(CG.highwayBranchAngle, 0f, 90f);
                GL.EndVertical();
                GL.EndHorizontal();
            }
            if (roadMapGenerated)
            {
                GL.BeginHorizontal("Box");
                GL.FlexibleSpace();
                CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop);
                GL.FlexibleSpace();
                CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth);
                GL.FlexibleSpace();
                GL.EndHorizontal();

                if (DebugMode)
                {
                    showPreviewGUI();
                }
            }
            EGL.HelpBox("The 'Generate Road Map' button may take several tries to generate road map due to the random nature of the algorithm.", MessageType.Info);
            GL.BeginHorizontal();
            if (GL.Button("Generate Road Map"))
            {
                GameObject roadMap = GameObject.Find("RoadMap");
                GameObject nodes   = GameObject.Find("Nodes");


                if (roadMap != null)
                {
                    roadMap.SetActive(true);
                }
                if (nodes != null)
                {
                    nodes.SetActive(true);
                }
                generator.generateRoadMap();
                roadMapGenerated  = true;
                roadMeshGenerated = false;
            }

            EG.BeginDisabledGroup(!roadMapGenerated);
            if (GL.Button("Generate Road Meshes & Blocks"))
            {
                generator.generateRoadMeshes();
                generator.generateBlocks();
                roadMeshGenerated = true;
            }
            EG.EndDisabledGroup();
            GL.EndHorizontal();

            EG.BeginDisabledGroup(!roadMeshGenerated);
            if (GL.Button("Save and Proceed"))
            {
                showRoadMapUI       = false;
                showRoadMapAdvanced = false;
                showBuildingUI      = true;
                GameObject roadMap = GameObject.Find("RoadMap");
                if (roadMap != null)
                {
                    roadMap.SetActive(false);
                }
                GameObject nodes = GameObject.Find("Nodes");
                if (nodes != null)
                {
                    nodes.SetActive(false);
                }
                roadmapLabel = "4. Road Map Generation - COMPLETED ✔";
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
示例#28
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            if (base.targets.Length == 1)
            {
                this.DoToolbar();
            }
            this.m_ShowProbeModeRealtimeOptions.target = this.reflectionProbeMode == ReflectionProbeMode.Realtime;
            this.m_ShowProbeModeCustomOptions.target   = this.reflectionProbeMode == ReflectionProbeMode.Custom;
            EditorGUILayout.IntPopup(this.m_Mode, Styles.reflectionProbeMode, Styles.reflectionProbeModeValues, Styles.typeText, new GUILayoutOption[0]);
            if (!this.m_Mode.hasMultipleDifferentValues)
            {
                EditorGUI.indentLevel++;
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowProbeModeCustomOptions.faded))
                {
                    EditorGUILayout.PropertyField(this.m_RenderDynamicObjects, Styles.renderDynamicObjects, new GUILayoutOption[0]);
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = this.m_CustomBakedTexture.hasMultipleDifferentValues;
                    UnityEngine.Object obj2 = EditorGUILayout.ObjectField(Styles.customCubemapText, this.m_CustomBakedTexture.objectReferenceValue, typeof(Cubemap), false, new GUILayoutOption[0]);
                    EditorGUI.showMixedValue = false;
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_CustomBakedTexture.objectReferenceValue = obj2;
                    }
                }
                EditorGUILayout.EndFadeGroup();
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowProbeModeRealtimeOptions.faded))
                {
                    EditorGUILayout.PropertyField(this.m_RefreshMode, Styles.refreshMode, new GUILayoutOption[0]);
                    EditorGUILayout.PropertyField(this.m_TimeSlicingMode, Styles.timeSlicing, new GUILayoutOption[0]);
                    EditorGUILayout.Space();
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            GUILayout.Label(Styles.runtimeSettingsHeader, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(this.m_Importance, Styles.importanceText, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_IntensityMultiplier, Styles.intensityText, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_BoxProjection, Styles.boxProjectionText, new GUILayoutOption[0]);
            bool flag2 = SceneView.IsUsingDeferredRenderingPath() && (UnityEngine.Rendering.GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != UnityEngine.Rendering.BuiltinShaderMode.Disabled);

            using (new EditorGUI.DisabledScope(!flag2))
            {
                EditorGUILayout.PropertyField(this.m_BlendDistance, Styles.blendDistanceText, new GUILayoutOption[0]);
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowBoxOptions.faded))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.m_BoxSize, Styles.sizeText, new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_BoxOffset, Styles.centerText, new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    Vector3 center = this.m_BoxOffset.vector3Value;
                    Vector3 size   = this.m_BoxSize.vector3Value;
                    if (this.ValidateAABB(ref center, ref size))
                    {
                        this.m_BoxOffset.vector3Value = center;
                        this.m_BoxSize.vector3Value   = size;
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            GUILayout.Label(Styles.captureCubemapHeaderText, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(40f) };
            EditorGUILayout.IntPopup(this.m_Resolution, Styles.renderTextureSizes.ToArray(), Styles.renderTextureSizesValues.ToArray(), Styles.resolutionText, options);
            EditorGUILayout.PropertyField(this.m_HDR, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_ShadowDistance, new GUILayoutOption[0]);
            EditorGUILayout.IntPopup(this.m_ClearFlags, Styles.clearFlags, Styles.clearFlagsValues, Styles.clearFlagsText, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_BackgroundColor, Styles.backgroundColorText, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_CullingMask, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_UseOcclusionCulling, new GUILayoutOption[0]);
            EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarProperties, EditorGUI.s_NearAndFarLabels, 35f, new GUILayoutOption[0]);
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            if (base.targets.Length == 1)
            {
                ReflectionProbe target = (ReflectionProbe)base.target;
                if ((target.mode == ReflectionProbeMode.Custom) && (target.customBakedTexture != null))
                {
                    Cubemap customBakedTexture = target.customBakedTexture as Cubemap;
                    if ((customBakedTexture != null) && (customBakedTexture.mipmapCount == 1))
                    {
                        EditorGUILayout.HelpBox("No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored.", MessageType.Warning);
                    }
                }
            }
            this.DoBakeButton();
            EditorGUILayout.Space();
            base.serializedObject.ApplyModifiedProperties();
        }
        private void DoCacheServerSettings()
        {
            Assert.IsTrue(m_IsGlobalSettings);
            GUILayout.Space(10);
            GUILayout.Label(Content.cacheServer, EditorStyles.boldLabel);

            var overrideAddress = CacheServerPreferences.GetCommandLineRemoteAddressOverride();

            if (overrideAddress != null)
            {
                EditorGUILayout.HelpBox("Cache Server remote address forced via command line argument. To use the cache server address specified here please restart Unity without the -CacheServerIPAddress command line argument.", MessageType.Info, true);
            }

            int index = Mathf.Clamp((int)EditorSettings.cacheServerMode, 0, cacheServerModePopupList.Length - 1);

            CreatePopupMenu(Content.mode.text, cacheServerModePopupList, index, SetCacheServerMode);

            if (index != (int)CacheServerMode.Disabled)
            {
                bool isCacheServerEnabled = true;

                if (index == (int)CacheServerMode.AsPreferences)
                {
                    if (CacheServerPreferences.IsCacheServerV2Enabled)
                    {
                        var cacheServerIP = CacheServerPreferences.CachesServerV2Address;
                        cacheServerIP = string.IsNullOrEmpty(cacheServerIP) ? "Not set in preferences" : cacheServerIP;
                        EditorGUILayout.HelpBox(cacheServerIP, MessageType.None, false);
                    }
                    else
                    {
                        isCacheServerEnabled = false;
                        EditorGUILayout.HelpBox("Disabled", MessageType.None, false);
                    }
                }

                if (isCacheServerEnabled)
                {
                    var oldEndpoint = EditorSettings.cacheServerEndpoint;
                    var newEndpoint = EditorGUILayout.TextField(Content.cacheServerIPLabel, oldEndpoint);
                    if (newEndpoint != oldEndpoint)
                    {
                        EditorSettings.cacheServerEndpoint = newEndpoint;
                    }

                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button("Check Connection", GUILayout.Width(150)))
                    {
                        if (AssetDatabase.IsV2Enabled())
                        {
                            var    address = EditorSettings.cacheServerEndpoint.Split(':');
                            var    ip      = address[0];
                            UInt16 port    = 0; // If 0, will use the default set port
                            if (address.Length == 2)
                            {
                                port = Convert.ToUInt16(address[1]);
                            }

                            if (AssetDatabaseExperimental.CanConnectToCacheServer(ip, port))
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Success;
                            }
                            else
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Failure;
                            }
                        }
                        else
                        {
                            if (InternalEditorUtility.CanConnectToCacheServer())
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Success;
                            }
                            else
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Failure;
                            }
                        }
                    }

                    GUILayout.Space(25);

                    switch (m_CacheServerConnectionState)
                    {
                    case CacheServerConnectionState.Success:
                        EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, true);
                        break;

                    case CacheServerConnectionState.Failure:
                        EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, true);
                        break;

                    case CacheServerConnectionState.Unknown:
                        GUILayout.Space(44);
                        break;
                    }

                    EditorGUILayout.EndHorizontal();

                    var old      = EditorSettings.cacheServerNamespacePrefix;
                    var newvalue = EditorGUILayout.TextField(Content.cacheServerNamespacePrefixLabel, old);
                    if (newvalue != old)
                    {
                        EditorSettings.cacheServerNamespacePrefix = newvalue;
                    }

                    EditorGUI.BeginChangeCheck();
                    bool enableDownload = EditorSettings.cacheServerEnableDownload;
                    enableDownload = EditorGUILayout.Toggle(Content.cacheServerEnableDownloadLabel, enableDownload);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorSettings.cacheServerEnableDownload = enableDownload;
                    }

                    EditorGUI.BeginChangeCheck();
                    bool enableUpload = EditorSettings.cacheServerEnableUpload;
                    enableUpload = EditorGUILayout.Toggle(Content.cacheServerEnableUploadLabel, enableUpload);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorSettings.cacheServerEnableUpload = enableUpload;
                    }

                    bool enableAuth = EditorSettings.cacheServerEnableAuth;
                    using (new EditorGUI.DisabledScope(enableAuth))
                    {
                        EditorGUI.BeginChangeCheck();
                        bool enableTls = EditorSettings.cacheServerEnableTls;
                        enableTls = EditorGUILayout.Toggle(Content.cacheServerEnableTlsLabel, enableTls);
                        if (EditorGUI.EndChangeCheck())
                        {
                            EditorSettings.cacheServerEnableTls = enableTls;
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    enableAuth = EditorGUILayout.Toggle(Content.cacheServerEnableAuthLabel, enableAuth);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorSettings.cacheServerEnableAuth = enableAuth;
                        if (enableAuth)
                        {
                            EditorSettings.cacheServerEnableTls = true;
                        }
                    }

                    EditorGUI.indentLevel++;
                    using (new EditorGUI.DisabledScope(!enableAuth))
                    {
                        int authModeIndex = Convert.ToInt32(EditorUserSettings.GetConfigValue("cacheServerAuthMode"));
                        CreatePopupMenu(Content.mode.text, cacheServerAuthMode, authModeIndex, SetCacheServerAuthMode);

                        string oldUserVal = EditorUserSettings.GetConfigValue("cacheServerAuthUser");
                        var    newUserVal = EditorGUILayout.TextField(Content.cacheServerAuthUserLabel, oldUserVal);
                        if (newUserVal != oldUserVal)
                        {
                            EditorUserSettings.SetConfigValue("cacheServerAuthUser", newUserVal);
                        }

                        var oldPasswordVal = EditorUserSettings.GetConfigValue("cacheServerAuthPassword");
                        var newPasswordVal = EditorGUILayout.PasswordField(Content.cacheServerAuthPasswordLabel, oldPasswordVal);
                        if (newPasswordVal != oldPasswordVal)
                        {
                            EditorUserSettings.SetPrivateConfigValue("cacheServerAuthPassword", newPasswordVal);
                        }
                    }
                    EditorGUI.indentLevel--;
                }
            }
        }
示例#30
0
        public override void OnInspectorGUI()
        {
            if (initializeException != null)
            {
                ShowLoadErrorExceptionGUI(initializeException);
                ApplyRevertGUI();
                return;
            }

            extraDataSerializedObject.Update();

            var platforms = Compilation.CompilationPipeline.GetAssemblyDefinitionPlatforms();

            using (new EditorGUI.DisabledScope(false))
            {
                if (targets.Length > 1)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        var value = string.Join(", ", extraDataTargets.Select(t => t.name).ToArray());
                        EditorGUILayout.TextField(Styles.name, value, EditorStyles.textField);
                    }
                }
                else
                {
                    EditorGUILayout.PropertyField(m_AssemblyName, Styles.name);
                }

                GUILayout.Label(Styles.generalOptions, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_AllowUnsafeCode, Styles.allowUnsafeCode);
                EditorGUILayout.PropertyField(m_AutoReferenced, Styles.autoReferenced);
                EditorGUILayout.PropertyField(m_OverrideReferences, Styles.overrideReferences);

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                GUILayout.Label(Styles.defineConstraints, EditorStyles.boldLabel);
                m_DefineConstraints.DoLayoutList();

                GUILayout.Label(Styles.references, EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_UseGUIDs, Styles.useGUIDs);
                EditorGUILayout.EndVertical();

                if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).references != null && ((AssemblyDefinitionState)data).references.Any(x => x.asset == null)))
                {
                    EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                }

                m_ReferencesList.DoLayoutList();

                if (m_OverrideReferences.boolValue && !m_OverrideReferences.hasMultipleDifferentValues)
                {
                    GUILayout.Label(Styles.precompiledReferences, EditorStyles.boldLabel);

                    if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).precompiledReferences.Any(x => string.IsNullOrEmpty(x.path) && !string.IsNullOrEmpty(x.name))))
                    {
                        EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                    }

                    UpdatePrecompiledReferenceListEntry();
                    m_PrecompiledReferencesList.DoLayoutList();
                }


                GUILayout.Label(Styles.platforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);

                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUILayout.PropertyField(m_CompatibleWithAnyPlatform, Styles.anyPlatform);
                    if (change.changed)
                    {
                        // Invert state include/exclude compatibility of states that have the opposite compatibility,
                        // so all states are either include or exclude.
                        var compatibleWithAny = m_CompatibleWithAnyPlatform.boolValue;
                        var needToSwap        = extraDataTargets.Cast <AssemblyDefinitionState>().Where(p => p.compatibleWithAnyPlatform != compatibleWithAny).ToList();
                        extraDataSerializedObject.ApplyModifiedProperties();
                        foreach (var state in needToSwap)
                        {
                            InversePlatformCompatibility(state);
                        }
                        extraDataSerializedObject.Update();
                    }
                }

                if (!m_CompatibleWithAnyPlatform.hasMultipleDifferentValues)
                {
                    GUILayout.Label(m_CompatibleWithAnyPlatform.boolValue ? Styles.excludePlatforms : Styles.includePlatforms, EditorStyles.boldLabel);

                    for (int i = 0; i < platforms.Length; ++i)
                    {
                        SerializedProperty property;
                        if (i >= m_PlatformCompatibility.arraySize)
                        {
                            m_PlatformCompatibility.arraySize++;
                            property           = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                            property.boolValue = false;
                        }
                        else
                        {
                            property = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                        }
                        EditorGUILayout.PropertyField(property, new GUIContent(platforms[i].DisplayName));
                    }

                    EditorGUILayout.Space();

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(Styles.selectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = true;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    if (GUILayout.Button(Styles.deselectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = false;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label(Styles.versionDefines, EditorStyles.boldLabel);
                m_VersionDefineList.DoLayoutList();
                EditorGUILayout.EndVertical();
            }

            extraDataSerializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }