示例#1
0
    void OnGUI()
    {
        bool update = false;

        Color c;
        bool  b;
        int   i;
        float f;

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUIStyle.none);
        //visualDebugging = EditorGUILayout.BeginToggleGroup("Text Debugging", visualDebugging);
        EditorGUILayout.LabelField(new GUIContent("General options"), EditorStyles.boldLabel);
        //EditorGUILayout.HelpBox("General options for debugging and visual appearance", MessageType.Info);
        b = EditorGUILayout.Toggle(new GUIContent("Use GL_Lines", "Whether or not shapes should be drawn using GL_Lines og regular Gizmo lines. GL_Lines are visible in a build, but invisible in the SceneView"), drawGL_Lines);
        if (drawGL_Lines != b)
        {
            drawGL_Lines = b; update = true;
        }
        c = EditorGUILayout.ColorField(new GUIContent("Default shape color", "The color used by default in most Util visual debugging methods.\n(for instance: DrawSphere() will draw with this color if you do not specify another color)"), defaultColor);
        if (defaultColor != c)
        {
            defaultColor = c; update = true;
        }
        EditorGUILayout.Space();



        b = EditorGUILayout.BeginToggleGroup(new GUIContent("Text Debugging", "Uncheck TextDebugging to disable text messages sent via DebugLine() and DebugLinePersistent()"), textDebugging);
        if (textDebugging != b)
        {
            textDebugging = b; update = true;
        }
        EditorGUILayout.BeginHorizontal(GUIStyle.none);
        GUILayout.Label("Width:");
        f = EditorGUILayout.Slider(debugWindowWidth, 0.2f, 0.99f);
        if (debugWindowWidth != f)
        {
            debugWindowWidth = f; update = true;
        }
        GUILayout.Label("Height:");
        f = EditorGUILayout.Slider(debugWindowHeight, 0.05f, 0.99f);
        if (debugWindowHeight != f)
        {
            debugWindowHeight = f; update = true;
        }
        EditorGUILayout.EndHorizontal();
        i = (int)EditorGUILayout.IntSlider(new GUIContent("Debug line text size", "The size of the text used in DebugLine() and DebugLinePersistent()"), debugLineTextSize, 8, 20);
        if (debugLineTextSize != i)
        {
            debugLineTextSize = i; update = true;
        }
        c = EditorGUILayout.ColorField(new GUIContent("Debug line text color", "The color of the text used in DebugLine() and DebugLinePersistent()"), debugLineColor);
        if (debugLineColor != c)
        {
            debugLineColor = c; update = true;
        }
        b = EditorGUILayout.Toggle(new GUIContent("Debug line background", "Whether or not the persistent debug lines should have a background"), debugLineBackground);
        if (debugLineBackground != b)
        {
            debugLineBackground = b; update = true;
        }

        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        b = EditorGUILayout.BeginToggleGroup(new GUIContent("Game Object Debugging", "Uncheck Game Object Debugging to disable debug messages sent via DebugOnObject()"), objectDebugging);
        if (objectDebugging != b)
        {
            objectDebugging = b; update = true;
        }
        i = (int)EditorGUILayout.IntSlider(new GUIContent("Debug Object text size", "The size of the text used in DebugOnObject()"), debugObjectTextSize, 10, 100);
        if (debugObjectTextSize != i)
        {
            debugObjectTextSize = i; update = true;
        }
        c = EditorGUILayout.ColorField(new GUIContent("Debug line text color", "The color of the text used in DebugLine() and DebugLinePersistent()"), debugObjectColor);
        if (debugObjectColor != c)
        {
            debugObjectColor = c; update = true;
        }
        b = EditorGUILayout.Toggle(new GUIContent("Debug object background", "Whether or not the persistent debug lines should have a background"), debugObjectBackground);
        if (debugObjectBackground != b)
        {
            debugObjectBackground = b; update = true;
        }
        b = EditorGUILayout.Toggle(new GUIContent("Scale with distance", "Uncheck to disable scaling of windows based on distance to Game Object"), scaleWithDistance);
        if (scaleWithDistance != b)
        {
            scaleWithDistance = b; update = true;
        }
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        b = EditorGUILayout.BeginToggleGroup(new GUIContent("Graph Values", "Uncheck Graph Values to disable displaying the information though Graph()"), drawGraph);
        if (drawGraph != b)
        {
            drawGraph = b; update = true;
        }
        Rect r = (Rect)EditorGUILayout.RectField(graphRect);

        if (graphRect != r)
        {
            graphRect = r; update = true;
        }
        f = EditorGUILayout.FloatField(new GUIContent("Graph Update Time", "The time between the graph debugger updates the values. 0 means every frame"), graphUpdateTime);
        if (graphUpdateTime != f)
        {
            graphUpdateTime = f; update = true;
        }

        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.EndScrollView();

        if (update)
        {
            UpdateValues();
        }
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        IsOpenOriginInspector = GUILayout.Toggle(IsOpenOriginInspector, new GUIContent("開啟原始面板"));
        if (IsOpenOriginInspector)
        {
            base.OnInspectorGUI();

            GUILayout.Space(20f);
        }

        GUILayout.BeginVertical("Box");
        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.TipSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("TipSound"),
            "是否啟用",
            "播放提示音效"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.CorrectSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("CorrectSound"),
            "是否啟用",
            "正確音效"
            );
        GUILayout.EndVertical();

        GUILayout.Space(20f);

        GUILayout.BeginVertical("Box");

        Instance.OtherAnimObjs.ShowInBeginOnOff = EditorGUILayout.Toggle("是否一開始就顯示圖片", Instance.OtherAnimObjs.ShowInBeginOnOff);

        Instance.OtherAnimObjs.OtherAnimObjOnOff = EditorGUILayout.BeginToggleGroup("額外動畫物件", Instance.OtherAnimObjs.OtherAnimObjOnOff);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("OtherAnimObjs").FindPropertyRelative("OtherAnimObjPrefab"), new GUIContent("額外動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("OtherAnimObjs").FindPropertyRelative("OtherAnimObjPosition"), new GUIContent("額外動畫的位置"));
        if (GUILayout.Button("選擇額外動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.OtherAnimObjs.OtherAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("額外動畫位置", obj, (pos) => {
                float x = Mathf.RoundToInt((pos.x * 100f)) / 100f;
                float y = Mathf.RoundToInt((pos.y * 100f)) / 100f;
                Instance.OtherAnimObjs.OtherAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }
        EditorGUILayout.EndToggleGroup();
        EditorGUILayout.EndVertical();

        GUILayout.Space(20f);


        matchPosFoldout = EditorGUILayout.Foldout(matchPosFoldout, "感應區圖片、正確物件資訊");
        if (matchPosFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("MatchPosItems"), typeof(MatchPosItem_matchC), MatchItemPost_ArrayEditorMiddle, MatchItemPost_ArrayEditorTrail);
        }

        moveItemsFoldout = EditorGUILayout.Foldout(moveItemsFoldout, "拖曳物件的圖片、物件資訊");
        if (moveItemsFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("MoveItems"), typeof(MoveItem_matchC), MoveItem_ArrayEditorMiddle, MoveItem_ArrayEditorTrail);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(Instance);
            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(Instance.gameObject.scene);
        }

        serializedObject.ApplyModifiedProperties();
    }
示例#3
0
        protected void DrawOtherTool()
        {
            //其他
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                animBool_other.target = EditorGUILayout.BeginToggleGroup("其他", animBool_other.target);

                if (EditorGUILayout.BeginFadeGroup(animBool_other.faded))
                {
                    if (GUILayout.Button("帮助文档"))
                    {
                        OpenDocument();
                    }

                    EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                    {
                        if (GUILayout.Button("创建镜头检测器<Checker>"))
                        {
                            var objs       = GameObject.FindObjectsOfType <SimpleController>();
                            int displaySet = EditorPrefs.GetInt(checkerDisplayKey, 0);
                            if (objs.Length > 0)
                            {
                                if (objs.Length > 0)
                                {
                                    util.SetIcon(objs[0].gameObject, util.Icon.CirclePurple);
                                }

                                if (displaySet != 2)
                                {
                                    var res = EditorUtility.DisplayDialogComplex("提醒", "场景中已经存在镜头检测器了,帮你标成圆形紫色,并选中它了", "选中", "关闭", "不再提示");
                                    Debug.Log(res);
                                    EditorPrefs.SetInt(checkerDisplayKey, res);
                                }
                                Selection.activeGameObject = objs[0].gameObject;
                                return;
                            }

                            var checker = new GameObject("Checker", new Type[] { typeof(SimpleController) });
                            Selection.activeGameObject = checker;
                            Undo.RegisterCreatedObjectUndo(checker, "General Checker");
                            util.SetIcon(checker, util.Icon.CirclePurple);


                            Mesh mesh;
                            if (util.TryGetCameraMesh(out mesh))
                            {
                                mesh.SetTarget(checker.transform);
                                checker.transform.SetParent(mesh.transform, false);
                                checker.transform.position = Vector3.zero;
                                //如果有顶点,放到第一个顶点那里去
                                var vertices = mesh.GetAllVertices();
                                if (vertices.Count > 0 && vertices[0] != null)
                                {
                                    checker.transform.position = vertices[0].transform.position;
                                }
                            }
                        }

                        FixedCheckerPositionToMeshSurface = EditorPrefs.GetBool("FixedCheckerPositionToMeshSurface", true);
                        FixedCheckerPositionToMeshSurface = EditorGUILayout.ToggleLeft("贴合网格表面", FixedCheckerPositionToMeshSurface, GUILayout.MaxWidth(86));
                        if (SimpleController.current != null)
                        {
                            SimpleController.current.FixedPositionToMeshsSurface = FixedCheckerPositionToMeshSurface;
                            EditorPrefs.SetBool("FixedCheckerPositionToMeshSurface", FixedCheckerPositionToMeshSurface);
                        }
                    }
                    EditorGUILayout.EndHorizontal();


                    if (GUILayout.Button("选择网格对象"))
                    {
                        var objs = GameObject.FindObjectsOfType <Mesh>();

                        var gobjs = new List <Object>();
                        for (int i = 0; i < objs.Length; i++)
                        {
                            gobjs.Add(objs[i].gameObject);
                        }

                        Selection.objects = gobjs.ToArray();
                    }

                    if (GUILayout.Button("显示/隐藏所有标记"))
                    {
                        MeshObjectIconVisualize(!maskSwitch);
                    }


                    if (GUILayout.Button("显示/隐藏网格"))
                    {
                        Mesh tCamearMesh = null;

                        if (util.TryGetCameraMesh(out tCamearMesh))
                        {
                            MeshVisualize(!tCamearMesh.GizmosOn);
                        }
                    }

                    //if (GUILayout.Button("测试"))
                    //{
                    //    Debug.Log(GetScriptStorePath());
                    //}
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }
        }
    void OnGUI()
    {
        GUILayout.Label("Excel Importer", EditorStyles.boldLabel);

        #region Single Excel
        if (isSingleExcel)
        {
            #region Path
            EditorGUILayout.BeginVertical("box");
            GUILayout.BeginHorizontal();
            scriptSavePath = EditorGUILayout.TextField("Script Save Path", scriptSavePath);
            if (GUILayout.Button("Open", GUILayout.MaxWidth(45)))
            {
                string path = EditorUtility.SaveFolderPanel("Database Path", dataPath + "/" + scriptSavePath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    scriptSavePath = path.Replace(dataPath, "") + "/";
                    EditorPrefs.SetString("ScriptSavePath", scriptSavePath);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            databasePath = EditorGUILayout.TextField("Database Path", databasePath);
            if (GUILayout.Button("Open", GUILayout.MaxWidth(45)))
            {
                string path = Application.dataPath + databasePath;
                if (!File.Exists(path))
                {
                    path = Application.dataPath;
                }
                path = EditorUtility.SaveFilePanel("Database Path", path, "Static.db", "db");
                if (!string.IsNullOrEmpty(path))
                {
                    databasePath = path.Replace(Application.dataPath, "");
                    EditorPrefs.SetString("DatabasePath", databasePath);
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            #endregion

            #region GUI

            if (null != sheetParameters)
            {
                scrollPos   = EditorGUILayout.BeginScrollView(scrollPos);
                sheetLength = sheetParameters.Count;
                for (int i = 0; i < sheetLength; i++)
                {
                    if (!sheetParameters[i].IsCreated)
                    {
                        EditorGUILayout.BeginVertical("box");
                        GUILayout.BeginHorizontal();
                        sheetParameters[i].SheetName = EditorGUILayout.TextField("Class Name",
                                                                                 sheetParameters[i].SheetName);

                        sheetParameters[i].IsEnable = EditorGUILayout.BeginToggleGroup("Enable",
                                                                                       sheetParameters[i].IsEnable);
                        EditorGUILayout.EndToggleGroup();
                        GUILayout.EndHorizontal();

                        if (sheetParameters[i].IsEnable)
                        {
                            int length = sheetParameters[i].ColParameters.Length;
                            for (int j = 0; j < length; j++)
                            {
                                sheetParameters[i].ColParameters[j].IsEnable
                                    = EditorGUILayout.BeginToggleGroup(
                                          ////sheetParameters[i].ColParameters[j].IsArray
                                          //    ? "Enable                                                                                        [Array]"
                                          //    : "Enable",
                                          "Enable",
                                          sheetParameters[i].ColParameters[j].IsEnable);

                                GUILayout.BeginHorizontal();
                                sheetParameters[i].ColParameters[j].Name =
                                    EditorGUILayout.TextField(sheetParameters[i].ColParameters[j].Name,
                                                              GUILayout.MaxWidth(160));
                                sheetParameters[i].ColParameters[j].Describe =
                                    EditorGUILayout.TextField(sheetParameters[i].ColParameters[j].Describe,
                                                              GUILayout.MaxWidth(240));
                                sheetParameters[i].ColParameters[j].Type =
                                    (ValueType)
                                    EditorGUILayout.EnumPopup(sheetParameters[i].ColParameters[j].Type,
                                                              GUILayout.MaxWidth(100));
                                GUILayout.EndHorizontal();

                                EditorGUILayout.EndToggleGroup();
                            }
                        }

                        if (GUILayout.Button("Create"))
                        {
                            try
                            {
                                CreateScript(sheetParameters[i].SheetName, sheetParameters[i].ColParameters,
                                             scriptSavePath);

                                CreateDatabaseTable(sheetParameters[i].SheetName, sheetParameters[i].ColParameters,
                                                    sheetParameters[i].SheetData,
                                                    databasePath);

                                sheetParameters[i].IsCreated = true;

                                CloseWindows();
                            }
                            catch (Exception e)
                            {
                                throw new Exception(e.Message);
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                }

                EditorGUILayout.EndScrollView();
            }

            #endregion
        }
        #endregion

        #region Multiple Excel
        else
        {
            #region Tittle
            EditorGUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();
            GUI.enabled = isPreviewBtnEnabled;
            excelPath   = EditorGUILayout.TextField("Excel Path", excelPath);
            if (GUILayout.Button("Open", GUILayout.MaxWidth(45)))
            {
                string path = EditorUtility.OpenFolderPanel("Excle Path", excelPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    EditorPrefs.SetString("ExcelPath", excelPath);
                }
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;
            if (isPreviewBtnEnabled && GUILayout.Button("Preview"))
            {
                isPreviewBtnEnabled = false;
                LoadAllExcel(excelPath);
            }

            if (!isPreviewBtnEnabled && GUILayout.Button("Reset"))
            {
                isPreviewBtnEnabled = true;
                isLoadFinished      = false;
                sheetParameters     = null;
            }
            #endregion
            if (isLoadFinished)
            {
                if (null != sheetParameters)
                {
                    #region Path
                    EditorGUILayout.BeginVertical("box");
                    GUILayout.BeginHorizontal();
                    scriptSavePath = EditorGUILayout.TextField("Script Save Path", scriptSavePath);
                    if (GUILayout.Button("Open", GUILayout.MaxWidth(45)))
                    {
                        string path = EditorUtility.SaveFolderPanel("Database Path", dataPath + "/" + scriptSavePath, "");
                        if (!string.IsNullOrEmpty(path))
                        {
                            scriptSavePath = path.Replace(dataPath, "") + "/";
                            EditorPrefs.SetString("ScriptSavePath", scriptSavePath);
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    databasePath = EditorGUILayout.TextField("Database Path", databasePath);
                    if (GUILayout.Button("Open", GUILayout.MaxWidth(45)))
                    {
                        string path = Application.dataPath + databasePath;
                        if (!File.Exists(path))
                        {
                            path = Application.dataPath;
                        }
                        path = EditorUtility.SaveFilePanel("Database Path", path, "Static.db", "db");
                        if (!string.IsNullOrEmpty(path))
                        {
                            databasePath = path.Replace(dataPath, "") + "/";
                            EditorPrefs.SetString("DatabasePath", databasePath);
                        }
                    }
                    GUILayout.EndHorizontal();
                    if (GUILayout.Button("Create All"))
                    {
                        for (int i = 0; i < sheetLength; ++i)
                        {
                            if (!sheetParameters[i].IsCreated)
                            {
                                CreateScript(sheetParameters[i].SheetName, sheetParameters[i].ColParameters,
                                             scriptSavePath);

                                CreateDatabaseTable(sheetParameters[i].SheetName, sheetParameters[i].ColParameters,
                                                    sheetParameters[i].SheetData,
                                                    databasePath);

                                sheetParameters[i].IsCreated = true;
                            }
                        }

                        CloseWindows();
                    }
                    EditorGUILayout.EndVertical();
                    #endregion

                    #region GUI
                    scrollPos   = EditorGUILayout.BeginScrollView(scrollPos);
                    sheetLength = sheetParameters.Count;
                    for (int i = 0; i < sheetLength; i++)
                    {
                        if (!sheetParameters[i].IsCreated)
                        {
                            EditorGUILayout.BeginVertical("box");
                            GUILayout.BeginHorizontal();
                            sheetParameters[i].SheetName = EditorGUILayout.TextField("Class Name",
                                                                                     sheetParameters[i].SheetName);

                            sheetParameters[i].IsEnable = EditorGUILayout.BeginToggleGroup("Enable",
                                                                                           sheetParameters[i].IsEnable);
                            EditorGUILayout.EndToggleGroup();
                            GUILayout.EndHorizontal();

                            if (sheetParameters[i].IsEnable)
                            {
                                int length = sheetParameters[i].ColParameters.Length;
                                for (int j = 0; j < length; j++)
                                {
                                    sheetParameters[i].ColParameters[j].IsEnable
                                        = EditorGUILayout.BeginToggleGroup(
                                              ////sheetParameters[i].ColParameters[j].IsArray
                                              //    ? "Enable                                                                                        [Array]"
                                              //    : "Enable",
                                              "Enable",
                                              sheetParameters[i].ColParameters[j].IsEnable);

                                    GUILayout.BeginHorizontal();
                                    sheetParameters[i].ColParameters[j].Name =
                                        EditorGUILayout.TextField(sheetParameters[i].ColParameters[j].Name,
                                                                  GUILayout.MaxWidth(160));
                                    sheetParameters[i].ColParameters[j].Describe =
                                        EditorGUILayout.TextField(sheetParameters[i].ColParameters[j].Describe,
                                                                  GUILayout.MaxWidth(240));
                                    sheetParameters[i].ColParameters[j].Type =
                                        (ValueType)
                                        EditorGUILayout.EnumPopup(sheetParameters[i].ColParameters[j].Type,
                                                                  GUILayout.MaxWidth(100));
                                    GUILayout.EndHorizontal();

                                    EditorGUILayout.EndToggleGroup();
                                }
                            }

                            if (GUILayout.Button("Create"))
                            {
                                try
                                {
                                    CreateScript(sheetParameters[i].SheetName, sheetParameters[i].ColParameters,
                                                 scriptSavePath);

                                    CreateDatabaseTable(sheetParameters[i].SheetName, sheetParameters[i].ColParameters,
                                                        sheetParameters[i].SheetData,
                                                        databasePath);

                                    sheetParameters[i].IsCreated = true;

                                    if (++createdSheetCount == sheetLength)
                                    {
                                        CloseWindows();
                                    }
                                }
                                catch (Exception e)
                                {
                                    throw new Exception(e.Message);
                                }
                            }
                            EditorGUILayout.EndVertical();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                    #endregion
                }
            }
            EditorGUILayout.EndVertical();

            #endregion
        }
    }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        void OnGUI()
        {
            var serialised_object = new SerializedObject(this);

            this._simulation_manager = FindObjectOfType <PausableManager>();
            if (this._simulation_manager)
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.BeginVertical();
                GUILayout.Label(
                    this._neodroid_icon,
                    GUILayout.Width(_logo_image_size),
                    GUILayout.Height(_logo_image_size));

                if (NeodroidEditorUtilities.LinkLabel(new GUIContent(_neodroid_url_text)))
                {
                    Application.OpenURL(_neodroid_url);
                }

                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();
                EditorGUILayout.ObjectField(this._simulation_manager, typeof(NeodroidManager), true);

                this._simulation_manager.Configuration = (SimulatorConfiguration)EditorGUILayout.ObjectField(
                    (SimulatorConfiguration)this._simulation_manager.Configuration,
                    typeof(SimulatorConfiguration),
                    true);

                this._simulation_manager.Configuration.FrameSkips = EditorGUILayout.IntField(
                    "Frame Skips",
                    this._simulation_manager.Configuration.FrameSkips);
                this._simulation_manager.Configuration.ResetIterations = EditorGUILayout.IntField(
                    "Reset Iterations",
                    this._simulation_manager.Configuration.ResetIterations);
                this._simulation_manager.Configuration.SimulationType = (SimulationType)EditorGUILayout.EnumPopup(
                    "Simulation Type",
                    this._simulation_manager.Configuration.SimulationType);
                this._simulation_manager.TestMotors = EditorGUILayout.Toggle(
                    "Test Motors",
                    this._simulation_manager.TestMotors);

                this._player_reactions = FindObjectOfType <PlayerReactions>();
                EditorGUILayout.ObjectField(this._player_reactions, typeof(PlayerReactions), true);

                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();

                this._environments = NeodroidUtilities.FindAllObjectsOfTypeInScene <PrototypingEnvironment>();
                if (this._show_environment_properties.Length != this._environments.Length)
                {
                    this.Setup();
                }

                this._scroll_position = EditorGUILayout.BeginScrollView(this._scroll_position);

                EditorGUILayout.BeginVertical("Box");
                var num_active_environments   = this._environments.Length; //TODO: Calculate actual number
                var num_inactive_environments =
                    this._environments.Length - num_active_environments;   //TODO: Calculate actual number
                GUILayout.Label(
                    $"Environments - Active({num_active_environments}), Inactive({num_inactive_environments}), Total({this._environments.Length})");
                if (this._show_environment_properties != null)
                {
                    for (var i = 0; i < this._show_environment_properties.Length; i++)
                    {
                        if (this._environments[i].isActiveAndEnabled)
                        {
                            this._show_environment_properties[i] = EditorGUILayout.Foldout(
                                this._show_environment_properties[i],
                                $"{this._environments[i].Identifier}");
                            if (this._show_environment_properties[i])
                            {
                                var actors        = this._environments[i].Actors;
                                var observers     = this._environments[i].Observers;
                                var configurables = this._environments[i].Configurables;
                                var resetables    = this._environments[i].Resetables;
                                var listeners     = this._environments[i].Listeners;
                                var displayers    = this._environments[i].Displayers;

                                EditorGUILayout.BeginVertical("Box");
                                this._environments[i].enabled = EditorGUILayout.BeginToggleGroup(
                                    this._environments[i].Identifier,
                                    this._environments[i].enabled && this._environments[i].gameObject.activeSelf);
                                EditorGUILayout.ObjectField(this._environments[i], typeof(PrototypingEnvironment), true);
                                this._environments[i].CoordinateSystem = (CoordinateSystem)EditorGUILayout.EnumPopup(
                                    "Coordinate system",
                                    this._environments[i].CoordinateSystem);
                                EditorGUI.BeginDisabledGroup(
                                    this._environments[i].CoordinateSystem != CoordinateSystem.Relative_to_reference_point_);
                                this._environments[i].CoordinateReferencePoint = (Transform)EditorGUILayout.ObjectField(
                                    "Reference point",
                                    this._environments[i].CoordinateReferencePoint,
                                    typeof(Transform),
                                    true);
                                EditorGUI.EndDisabledGroup();
                                this._environments[i].ObjectiveFunction = (ObjectiveFunction)EditorGUILayout.ObjectField(
                                    "Objective function",
                                    (ObjectiveFunction)this._environments[i].ObjectiveFunction,
                                    typeof(ObjectiveFunction),
                                    true);
                                this._environments[i].EpisodeLength = EditorGUILayout.IntField(
                                    "Episode Length",
                                    this._environments[i].EpisodeLength);

                                EditorGUI.BeginDisabledGroup(true);
                                EditorGUILayout.LabelField("Info:");
                                EditorGUILayout.Toggle("Terminated", this._environments[i].Terminated);
                                EditorGUI.EndDisabledGroup();

                                EditorGUILayout.BeginVertical("Box");
                                GUILayout.Label("Actors");
                                foreach (var actor in actors)
                                {
                                    var actor_value = (Actor)actor.Value;
                                    if (actor_value != null)
                                    {
                                        var motors = actor_value.Motors;

                                        EditorGUILayout.BeginVertical("Box");

                                        actor_value.enabled = EditorGUILayout.BeginToggleGroup(
                                            actor.Key,
                                            actor_value.enabled && actor_value.gameObject.activeSelf);
                                        EditorGUILayout.ObjectField(actor_value, typeof(Actor), true);

                                        EditorGUILayout.BeginVertical("Box");
                                        GUILayout.Label("Motors");
                                        foreach (var motor in motors)
                                        {
                                            var motor_value = (Motor)motor.Value;
                                            if (motor_value != null)
                                            {
                                                EditorGUILayout.BeginVertical("Box");
                                                motor_value.enabled = EditorGUILayout.BeginToggleGroup(
                                                    motor.Key,
                                                    motor_value.enabled && motor_value.gameObject.activeSelf);
                                                EditorGUILayout.ObjectField(motor_value, typeof(Motor), true);
                                                EditorGUILayout.EndToggleGroup();

                                                EditorGUILayout.EndVertical();
                                            }
                                        }

                                        EditorGUILayout.EndVertical();

                                        EditorGUILayout.EndToggleGroup();

                                        EditorGUILayout.EndVertical();
                                    }
                                }

                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical("Box");
                                GUILayout.Label("Observers");
                                foreach (var observer in observers)
                                {
                                    var observer_value = (Observer)observer.Value;
                                    if (observer_value != null)
                                    {
                                        EditorGUILayout.BeginVertical("Box");
                                        observer_value.enabled = EditorGUILayout.BeginToggleGroup(
                                            observer.Key,
                                            observer_value.enabled && observer_value.gameObject.activeSelf);
                                        EditorGUILayout.ObjectField(observer_value, typeof(Observer), true);
                                        EditorGUILayout.EndToggleGroup();
                                        EditorGUILayout.EndVertical();
                                    }
                                }

                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical("Box");
                                GUILayout.Label("Configurables");
                                foreach (var configurable in configurables)
                                {
                                    var configurable_value = (Configurable)configurable.Value;
                                    if (configurable_value != null)
                                    {
                                        EditorGUILayout.BeginVertical("Box");
                                        configurable_value.enabled = EditorGUILayout.BeginToggleGroup(
                                            configurable.Key,
                                            configurable_value.enabled && configurable_value.gameObject.activeSelf);
                                        EditorGUILayout.ObjectField(configurable_value, typeof(Configurable), true);
                                        EditorGUILayout.EndToggleGroup();
                                        EditorGUILayout.EndVertical();
                                    }
                                }

                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical("Box");
                                GUILayout.Label("Displayers");
                                foreach (var displayer in displayers)
                                {
                                    var displayer_value = (Displayer)displayer.Value;
                                    if (displayer_value != null)
                                    {
                                        EditorGUILayout.BeginVertical("Box");
                                        displayer_value.enabled = EditorGUILayout.BeginToggleGroup(
                                            displayer.Key,
                                            displayer_value.enabled && displayer_value.gameObject.activeSelf);
                                        EditorGUILayout.ObjectField(displayer_value, typeof(Displayer), true);
                                        EditorGUILayout.EndToggleGroup();
                                        EditorGUILayout.EndVertical();
                                    }
                                }

                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical("Box");

                                /*
                                 * GUILayout.Label("Internals");
                                 * foreach (var resetable in resetables) {
                                 * var resetable_value = (Resetable) resetable.Value;
                                 * if (resetable_value != null) {
                                 *
                                 *  EditorGUILayout.BeginVertical("Box");
                                 *  resetable_value.enabled = EditorGUILayout.BeginToggleGroup(
                                 *      resetable.Key,
                                 *      resetable_value.enabled && resetable_value.gameObject.activeSelf);
                                 *  EditorGUILayout.ObjectField(resetable_value, typeof(Resetable), true);
                                 *  EditorGUILayout.EndToggleGroup();
                                 *  EditorGUILayout.EndVertical();
                                 * }
                                 * }
                                 */

/*
 *              foreach (var listener in listeners) {
 *                if (listener.Value != null) {
 *                  EditorGUILayout.BeginVertical("Box");
 *                  listener.Value.enabled = EditorGUILayout.BeginToggleGroup(
 *                      listener.Key,
 *                      listener.Value.enabled && listener.Value.gameObject.activeSelf);
 *                  EditorGUILayout.ObjectField(listener.Value, typeof(EnvironmentListener), true);
 *                  EditorGUILayout.EndToggleGroup();
 *                  EditorGUILayout.EndVertical();
 *                }
 *              }
 */
                                EditorGUILayout.EndVertical();

                                EditorGUILayout.EndToggleGroup();
                                EditorGUILayout.EndVertical();
                            }
                        }
                    }

                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical("Box");
                    GUILayout.Label("Disabled environments");
                    for (var i = 0; i < this._show_environment_properties.Length; i++)
                    {
                        if (!this._environments[i].isActiveAndEnabled)
                        {
                            EditorGUILayout.ObjectField(this._environments[i], typeof(NeodroidEnvironment), true);
                        }
                    }

                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndScrollView();
                    serialised_object.ApplyModifiedProperties();

                    /*
                     * if (GUILayout.Button("Refresh")) {
                     * this.Refresh();
                     * }
                     *
                     * EditorGUI.BeginDisabledGroup(!Application.isPlaying);
                     *
                     * if (GUILayout.Button("Step")) {
                     * this._simulation_manager.ReactAndCollectStates(
                     *    new Reaction(
                     *        new ReactionParameters(true, true, episode_count:true),
                     *        null,
                     *        null,
                     *        null,
                     *        null,
                     *        ""));
                     * }
                     *
                     * if (GUILayout.Button("Reset")) {
                     * this._simulation_manager.ReactAndCollectStates(
                     *    new Reaction(
                     *        new ReactionParameters(true, false, true, episode_count:true),
                     *        null,
                     *        null,
                     *        null,
                     *        null,
                     *        ""));
                     * }
                     *
                     * EditorGUI.EndDisabledGroup();
                     */
                }
            }
        }
示例#6
0
    public override void OnInspectorGUI()
    {
        EasyTouch t = (EasyTouch)target;

        HTGUILayout.FoldOut(ref t.showGeneral, "General properties", false);
        if (t.showGeneral)
        {
            if (t.enable)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enable = EditorGUILayout.Toggle("Enable EasyTouch", t.enable);
            if (t.enableRemote)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enableRemote = EditorGUILayout.Toggle("Enable unity remote", t.enableRemote);


            if (t.useBroadcastMessage)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.useBroadcastMessage = EditorGUILayout.BeginToggleGroup("Broadcast messages", t.useBroadcastMessage);
            GUI.backgroundColor   = Color.white;
            if (t.useBroadcastMessage)
            {
                EditorGUILayout.BeginVertical(paddingStyle1);
                t.receiverObject = (GameObject)EditorGUILayout.ObjectField("Other receiver", t.receiverObject, typeof(GameObject), true);
                if (t.isExtension)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.isExtension       = EditorGUILayout.Toggle("Joysticks & buttons", t.isExtension);
                GUI.backgroundColor = Color.white;
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.Space();

            if (t.enableReservedArea)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enableReservedArea = EditorGUILayout.Toggle("Enable reserved area", t.enableReservedArea);
            EditorGUILayout.Space();
            if (t.enabledNGuiMode)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enabledNGuiMode   = EditorGUILayout.Toggle("Enable NGUI compatibilty", t.enabledNGuiMode);
            GUI.backgroundColor = Color.white;
            if (t.enabledNGuiMode)
            {
                EditorGUILayout.BeginVertical(paddingStyle1);

                // Camera
                serializedObject.Update();
                //EditorGUIUtility.LookLikeInspector();
                SerializedProperty cameras = serializedObject.FindProperty("nGUICameras");
                EditorGUILayout.PropertyField(cameras, true);
                serializedObject.ApplyModifiedProperties();
                //EditorGUIUtility.LookLikeControls();

                EditorGUILayout.Space();

                // layers
                serializedObject.Update();
                //EditorGUIUtility.LookLikeInspector();
                SerializedProperty layers = serializedObject.FindProperty("nGUILayers");
                EditorGUILayout.PropertyField(layers, false);
                serializedObject.ApplyModifiedProperties();
                //EditorGUIUtility.LookLikeControls();

                EditorGUILayout.EndVertical();
            }
        }

        if (t.enable)
        {
            // Auto select porperties
            HTGUILayout.FoldOut(ref t.showSelect, "Auto-select properties", false);
            if (t.showSelect)
            {
                //	t.touchCameras = (Camera)EditorGUILayout.ObjectField("Camera",t.touchCameras,typeof(Camera),true);
                if (HTGUILayout.Button("Add Camera", Color.green, 100))
                {
                    t.touchCameras.Add(new ECamera(null, false));
                }
                for (int i = 0; i < t.touchCameras.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (HTGUILayout.Button("X", Color.red, 19))
                    {
                        t.touchCameras.RemoveAt(i);
                        i--;
                    }
                    if (i >= 0)
                    {
                        t.touchCameras[i].camera = (Camera)EditorGUILayout.ObjectField("", t.touchCameras[i].camera, typeof(Camera), true);
                        EditorGUILayout.LabelField("Gui", GUILayout.Width(50));
                        t.touchCameras[i].guiCamera = EditorGUILayout.Toggle("", t.touchCameras[i].guiCamera);
                        EditorGUILayout.EndHorizontal();
                    }
                }
                HTGUILayout.DrawSeparatorLine();

                if (t.autoSelect)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.autoSelect        = EditorGUILayout.Toggle("Enable auto-select", t.autoSelect);
                GUI.backgroundColor = Color.white;
                if (t.autoSelect)
                {
                    serializedObject.Update();
                    //EditorGUIUtility.LookLikeInspector();
                    SerializedProperty layers = serializedObject.FindProperty("pickableLayers");
                    EditorGUILayout.PropertyField(layers, true);
                    serializedObject.ApplyModifiedProperties();
                    //EditorGUIUtility.LookLikeControls();

                    EditorGUILayout.Space();

                    if (t.enable2D)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enable2D          = EditorGUILayout.Toggle("2D collider", t.enable2D);
                    GUI.backgroundColor = Color.white;
                    if (t.enable2D)
                    {
                        serializedObject.Update();
                        //EditorGUIUtility.LookLikeInspector();
                        layers = serializedObject.FindProperty("pickableLayers2D");
                        EditorGUILayout.PropertyField(layers, true);
                        serializedObject.ApplyModifiedProperties();
                        //EditorGUIUtility.LookLikeControls();
                    }
                }
            }

            // General gesture properties
            HTGUILayout.FoldOut(ref t.showGesture, "General gesture properties", false);
            if (t.showGesture)
            {
                t.StationnaryTolerance = EditorGUILayout.FloatField("Stationary tolerance", t.StationnaryTolerance);
                t.longTapTime          = EditorGUILayout.FloatField("Long tap time", t.longTapTime);
                t.swipeTolerance       = EditorGUILayout.FloatField("Swipe tolerance", t.swipeTolerance);
            }

            // Two fingers gesture
            HTGUILayout.FoldOut(ref t.showTwoFinger, "Two fingers gesture properties", false);
            if (t.showTwoFinger)
            {
                if (t.enable2FingersGesture)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.enable2FingersGesture = EditorGUILayout.Toggle("2 fingers gesture", t.enable2FingersGesture);
                GUI.backgroundColor     = Color.white;
                if (t.enable2FingersGesture)
                {
                    EditorGUILayout.Separator();
                    if (t.enablePinch)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enablePinch       = EditorGUILayout.Toggle("Enable Pinch", t.enablePinch);
                    GUI.backgroundColor = Color.white;
                    if (t.enablePinch)
                    {
                        t.minPinchLength = EditorGUILayout.FloatField("Min pinch length", t.minPinchLength);
                    }
                    EditorGUILayout.Separator();
                    if (t.enableTwist)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enableTwist       = EditorGUILayout.Toggle("Enable twist", t.enableTwist);
                    GUI.backgroundColor = Color.white;
                    if (t.enableTwist)
                    {
                        t.minTwistAngle = EditorGUILayout.FloatField("Min twist angle", t.minTwistAngle);
                    }

                    EditorGUILayout.Separator();
                }
            }

            // Second Finger simulation
            HTGUILayout.FoldOut(ref t.showSecondFinger, "Second finger simulation", false);
            if (t.showSecondFinger)
            {
                if (t.secondFingerTexture == null)
                {
                    t.secondFingerTexture = Resources.Load("secondFinger") as Texture;
                }

                t.secondFingerTexture = (Texture)EditorGUILayout.ObjectField("Texture", t.secondFingerTexture, typeof(Texture), true);
                EditorGUILayout.HelpBox("Change the keys settings for a fash compilation, or if you want to change the keys", MessageType.Info);
                t.twistKey = (KeyCode)EditorGUILayout.EnumPopup("Twist & pinch key", t.twistKey);
                t.swipeKey = (KeyCode)EditorGUILayout.EnumPopup("Swipe key", t.swipeKey);
            }
        }
    }
示例#7
0
        public override void OnInspectorGUI()
        {
            //Get our resource
            m_manager = (GaiaSessionManager)target;

            //Set up the box style
            if (m_boxStyle == null)
            {
                m_boxStyle = new GUIStyle(GUI.skin.box);
                m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
                m_boxStyle.fontStyle        = FontStyle.Bold;
                m_boxStyle.alignment        = TextAnchor.UpperLeft;
            }

            //Setup the wrap style
            if (m_wrapStyle == null)
            {
                m_wrapStyle          = new GUIStyle(GUI.skin.label);
                m_wrapStyle.wordWrap = true;
            }

            //Set up the description wrap style
            if (m_descWrapStyle == null)
            {
                m_descWrapStyle          = new GUIStyle(GUI.skin.textArea);
                m_descWrapStyle.wordWrap = true;
            }

            //Scroll
            m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition, false, false);

            //Create a nice text intro
            GUILayout.BeginVertical("Gaia Session Manager", m_boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("Track and control session creation and playback.", m_wrapStyle);
            GUILayout.Space(4);
            EditorGUILayout.BeginHorizontal();
            m_manager.m_session = (GaiaSession)EditorGUILayout.ObjectField(GetLabel("Session"), m_manager.m_session, typeof(GaiaSession), false);

            if (GUILayout.Button(GetLabel("New"), GUILayout.Width(45)))
            {
                m_manager.CreateSession();
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.EndVertical();

            if (m_manager.m_session == null)
            {
                GUILayout.EndScrollView();
                return;
            }

            //Track changes
            EditorGUI.BeginChangeCheck();

            //Make some space
            GUILayout.Space(4);

            //Wrap it up in a box
            GUILayout.BeginVertical(m_boxStyle);
            GUILayout.BeginVertical("Summary:", m_boxStyle);
            GUILayout.Space(20);


            //Display the basic details
            EditorGUILayout.LabelField("Name");
            if (m_manager.IsLocked())
            {
                GUI.enabled = false;
            }
            string name = EditorGUILayout.TextArea(m_manager.m_session.m_name, m_descWrapStyle, GUILayout.MinHeight(15));

            GUI.enabled = true;

            EditorGUILayout.LabelField("Description");
            if (m_manager.IsLocked())
            {
                GUI.enabled = false;
            }
            string description = EditorGUILayout.TextArea(m_manager.m_session.m_description, m_descWrapStyle, GUILayout.MinHeight(45));

            Texture2D previewImage = m_manager.GetPreviewImage();

            if (!m_manager.IsLocked())
            {
                previewImage = (Texture2D)EditorGUILayout.ObjectField(GetLabel("Preview Image"), m_manager.m_session.m_previewImage, typeof(Texture2D), false, GUILayout.MaxHeight(15f));
            }

            //Detect change in session and handle changes to preview image
            float width, height;

            if (m_manager.m_session.GetInstanceID() != m_lastSessionID)
            {
                m_lastPreviewImgName = "";
                m_lastSessionID      = m_manager.m_session.GetInstanceID();
                if (m_manager.HasPreviewImage())
                {
                    previewImage         = m_manager.GetPreviewImage();
                    m_lastPreviewImgName = previewImage.name;
                }
            }
            else //Process changes to preview image
            {
                if (previewImage == null)
                {
                    if (m_manager.IsLocked()) //Undo change if locked
                    {
                        if (m_manager.HasPreviewImage())
                        {
                            previewImage         = m_manager.GetPreviewImage();
                            m_lastPreviewImgName = previewImage.name;
                            Debug.LogWarning("You can not change the image on a locked session");
                        }
                    }
                    else
                    {
                        if (m_manager.HasPreviewImage())
                        {
                            m_manager.RemovePreviewImage();
                            m_lastPreviewImgName = "";
                        }
                    }
                }
                else
                {
                    //Handle changes to preview image
                    if (previewImage.name != m_lastPreviewImgName)
                    {
                        if (m_manager.IsLocked()) //Revert
                        {
                            if (m_manager.HasPreviewImage())
                            {
                                previewImage         = m_manager.GetPreviewImage();
                                m_lastPreviewImgName = previewImage.name;
                                Debug.LogWarning("You can not change the image on a locked session");
                            }
                            else
                            {
                                previewImage         = null;
                                m_lastPreviewImgName = "";
                            }
                        }
                        else
                        {
                            //Make it readable
                            Gaia.Utils.MakeTextureReadable(previewImage);

                            //Make a new texture from it
                            Texture2D newTexture = new Texture2D(previewImage.width, previewImage.height, TextureFormat.ARGB32, false);
                            newTexture.name = m_manager.m_session.m_name;
                            newTexture.SetPixels(previewImage.GetPixels(0));
                            newTexture.Apply();

                            //Resize and scale it
                            width  = 320;
                            height = previewImage.height * (width / previewImage.width);
                            Gaia.ScaleTexture.Bilinear(newTexture, (int)width, (int)height);

                            //Compress it
                            //newTexture.Compress(true);

                            //And store its content
                            m_manager.AddPreviewImage(newTexture);

                            //Assign back to the texture for the scene
                            previewImage         = newTexture;
                            m_lastPreviewImgName = previewImage.name;
                        }
                    }
                }
            }

            GUI.enabled = true; //In response to locked above

            if (previewImage != null)
            {
                //Get aspect ratio and available space and display the image
                width  = Screen.width - 43f;
                height = previewImage.height * (width / previewImage.width);
                GUILayout.Label(previewImage, GUILayout.MaxWidth(width), GUILayout.MaxHeight(height));
            }

            EditorGUILayout.LabelField("Created", m_manager.m_session.m_dateCreated);
            EditorGUILayout.LabelField("Dimensions", string.Format("w{0} d{1} h{2}", m_manager.m_session.m_terrainWidth, m_manager.m_session.m_terrainDepth, m_manager.m_session.m_terrainHeight));

            if (m_manager.IsLocked())
            {
                GUI.enabled = false;
            }
            m_manager.m_session.m_seaLevel = EditorGUILayout.Slider(GetLabel("Sea Level"), m_manager.m_session.m_seaLevel, 0f, m_manager.m_session.m_terrainDepth);
            GUI.enabled = true; //In response to locked above

            bool locked = EditorGUILayout.Toggle(GetLabel("Locked"), m_manager.m_session.m_isLocked);

            GUILayout.EndVertical();

            //Iterate through the operations
            GUILayout.BeginVertical("Operations:", m_boxStyle);
            GUILayout.Space(20);

            if (m_manager.m_session.m_operations.Count == 0)
            {
                GUILayout.Space(5);
                GUILayout.Label("No operations yet...");
                GUILayout.Space(5);
            }
            else
            {
                GaiaOperation op;
                EditorGUI.indentLevel++;
                for (int opIdx = 0; opIdx < m_manager.m_session.m_operations.Count; opIdx++)
                {
                    op = m_manager.m_session.m_operations[opIdx];

                    if (op.m_isActive)
                    {
                        op.m_isFoldedOut = EditorGUILayout.Foldout(op.m_isFoldedOut, op.m_description);
                    }
                    else
                    {
                        op.m_isFoldedOut = EditorGUILayout.Foldout(op.m_isFoldedOut, op.m_description + " [inactive]");
                    }

                    if (op.m_isFoldedOut)
                    {
                        EditorGUI.indentLevel++;

                        EditorGUILayout.LabelField("Description", op.m_description, m_wrapStyle);
                        EditorGUILayout.LabelField("Created", op.m_operationDateTime);
                        if (m_manager.m_session.m_isLocked)
                        {
                            GUI.enabled = false;
                        }
                        op.m_isActive = EditorGUILayout.Toggle(GetLabel("Active"), op.m_isActive);
                        GUI.enabled   = true;

                        int dataLength = 0;
                        for (int idx = 0; idx < op.m_operationDataJson.GetLength(0); idx++)
                        {
                            dataLength += op.m_operationDataJson[idx].Length;
                        }
                        EditorGUILayout.LabelField("Data", dataLength.ToString() + " bytes");

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (m_manager.m_session.m_isLocked)
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button(GetLabel("Delete")))
                        {
                            if (EditorUtility.DisplayDialog("Delete Operation ?", "Are you sure you want to delete this operation ?", "Yes", "No"))
                            {
                                m_manager.RemoveOperation(opIdx);
                            }
                        }
                        GUI.enabled = true;
                        if (GUILayout.Button(GetLabel("Apply")))
                        {
                            m_manager.Apply(opIdx);
                        }
                        if (GUILayout.Button(GetLabel("Play")))
                        {
                            m_manager.PlayOperation(opIdx);
                        }
                        GUILayout.EndHorizontal();

                        EditorGUI.indentLevel--;
                    }
                    //EditorGUILayout.Space();
                }
                EditorGUI.indentLevel--;
            }
            GUILayout.EndVertical();

            //Create a nice text intro
            if (!m_manager.m_session.m_isLocked)
            {
                GUILayout.BeginVertical(m_boxStyle);
                m_manager.m_genShowRandomGenerator = EditorGUILayout.BeginToggleGroup(GetLabel(" Random Terrain Generator"), m_manager.m_genShowRandomGenerator);
                if (m_manager.m_genShowRandomGenerator)
                {
                    m_manager.m_genNumStampsToGenerate = EditorGUILayout.IntSlider(GetLabel("Stamps"), m_manager.m_genNumStampsToGenerate, 1, 20);
                    m_manager.m_genScaleWidth          = EditorGUILayout.Slider(GetLabel("Width Scale"), m_manager.m_genScaleWidth, 0.5f, 100f);
                    m_manager.m_genScaleHeight         = EditorGUILayout.Slider(GetLabel("Height Scale"), m_manager.m_genScaleHeight, 0.5f, 100f);
                    m_manager.m_genBorderStyle         = (Gaia.GaiaConstants.GeneratorBorderStyle)EditorGUILayout.EnumPopup(GetLabel("Border Style"), m_manager.m_genBorderStyle);
                    m_manager.m_genChanceOfHills       = EditorGUILayout.Slider(GetLabel("Hill Chance"), m_manager.m_genChanceOfHills, 0f, 1f);
                    m_manager.m_genChanceOfIslands     = EditorGUILayout.Slider(GetLabel("Island Chance"), m_manager.m_genChanceOfIslands, 0f, 1f);
                    m_manager.m_genChanceOfLakes       = EditorGUILayout.Slider(GetLabel("Lake Chance"), m_manager.m_genChanceOfLakes, 0f, 1f);
                    m_manager.m_genChanceOfMesas       = EditorGUILayout.Slider(GetLabel("Mesa Chance"), m_manager.m_genChanceOfMesas, 0f, 1f);
                    m_manager.m_genChanceOfMountains   = EditorGUILayout.Slider(GetLabel("Mountain Chance"), m_manager.m_genChanceOfMountains, 0f, 1f);
                    m_manager.m_genChanceOfPlains      = EditorGUILayout.Slider(GetLabel("Plains Chance"), m_manager.m_genChanceOfPlains, 0f, 1f);
                    m_manager.m_genChanceOfRivers      = EditorGUILayout.Slider(GetLabel("River Chance"), m_manager.m_genChanceOfRivers, 0f, 1f);
                    m_manager.m_genChanceOfValleys     = EditorGUILayout.Slider(GetLabel("Valley Chance"), m_manager.m_genChanceOfValleys, 0f, 1f);
                    m_manager.m_genChanceOfVillages    = EditorGUILayout.Slider(GetLabel("Village Chance"), m_manager.m_genChanceOfVillages, 0f, 1f);
                    m_manager.m_genChanceOfWaterfalls  = EditorGUILayout.Slider(GetLabel("Waterfall Chance"), m_manager.m_genChanceOfWaterfalls, 0f, 1f);

                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(GetLabel("Reset Session")))
                    {
                        if (EditorUtility.DisplayDialog("Reset Session ?", "Are you sure you want to reset your session - this can not be undone ?", "Yes", "No"))
                        {
                            m_manager.ResetSession();
                        }
                    }
                    if (GUILayout.Button(GetLabel("Add Stamps")))
                    {
                        m_manager.RandomiseStamps();
                    }
                    GUILayout.EndHorizontal();
                }
                EditorGUILayout.EndToggleGroup();
                GUILayout.EndVertical();
            }

            //Create a nice text intro
            GUILayout.BeginVertical(m_boxStyle);
            m_manager.m_genShowTerrainHelper = EditorGUILayout.BeginToggleGroup(GetLabel(" Terrain Helper"), m_manager.m_genShowTerrainHelper);
            if (m_manager.m_genShowTerrainHelper)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(GetLabel("Flatten Terrain")))
                {
                    if (EditorUtility.DisplayDialog("Flatten Terrain?", "Are you sure you want to flatten your terrain - this can not be undone ?", "Yes", "No"))
                    {
                        GaiaWorldManager wm = new GaiaWorldManager(Terrain.activeTerrains);
                        wm.FlattenWorld();
                    }
                }
                if (GUILayout.Button(GetLabel("Smooth Terrain")))
                {
                    if (EditorUtility.DisplayDialog("Smooth Terrain?", "Are you sure you want to smooth your terrain - this can not be undone ?", "Yes", "No"))
                    {
                        GaiaWorldManager wm = new GaiaWorldManager(Terrain.activeTerrains);
                        wm.SmoothWorld();
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(GetLabel("Clear Trees")))
                {
                    if (EditorUtility.DisplayDialog("Clear Trees?", "Are you sure you want to clear your trees - this can not be undone ?", "Yes", "No"))
                    {
                        TerrainHelper.ClearTrees();
                    }
                }
                if (GUILayout.Button(GetLabel("Clear Details")))
                {
                    if (EditorUtility.DisplayDialog("Clear Details?", "Are you sure you want to clear your details / grass - this can not be undone ?", "Yes", "No"))
                    {
                        TerrainHelper.ClearDetails();
                    }
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();
            GUILayout.EndVertical();


            //Check for changes, make undo record, make changes and let editor know we are dirty
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(m_manager, "Made changes");
                m_manager.m_session.m_name         = name;
                m_manager.m_session.m_description  = description;
                m_manager.m_session.m_isLocked     = locked;
                m_manager.m_session.m_previewImage = previewImage;
                EditorUtility.SetDirty(m_manager.m_session);
                EditorUtility.SetDirty(m_manager);
            }

            GUILayout.BeginVertical("Session Controller", m_boxStyle);
            GUILayout.Space(20);

            GUILayout.BeginHorizontal();
            if (m_manager.m_updateSessionCoroutine == null && m_manager.m_updateOperationCoroutine == null)
            {
                if (GUILayout.Button(GetLabel("Play Session")))
                {
                    if (EditorUtility.DisplayDialog("Playback Session ?", "Are you sure you want to playback your session - this can not be undone ?", "Yes", "No"))
                    {
                        m_manager.PlaySession();
                    }
                }
                if (GUILayout.Button(GetLabel("Export Resources")))
                {
                    m_manager.ExportSessionResources();
                }
            }
            else
            {
                if (GUILayout.Button(GetLabel("Cancel")))
                {
                    m_manager.CancelPlayback();
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5);


            //Debug.Log(m_manager.m_lastUpdateDateTime);

            //Draw the various spawner progress bars
            if (m_manager.m_currentStamper != null)
            {
                if (m_manager.m_currentStamper.IsStamping())
                {
                    ProgressBar(string.Format("{0}:{1} ({2:0.0}%)", m_manager.m_currentStamper.gameObject.name, m_manager.m_currentStamper.m_stampPreviewImage.name, m_manager.m_currentStamper.m_stampProgress * 100f), m_manager.m_currentStamper.m_stampProgress);
                }
            }
            if (m_manager.m_currentSpawner != null)
            {
                if (m_manager.m_currentSpawner.IsSpawning())
                {
                    ProgressBar(string.Format("{0} ({1:0.0}%)", m_manager.m_currentSpawner.gameObject.name, m_manager.m_currentSpawner.m_spawnProgress * 100f), m_manager.m_currentSpawner.m_spawnProgress);
                }
            }

            GUILayout.EndVertical();


            GUILayout.EndVertical();

            //End scroll
            GUILayout.EndScrollView();
        }
示例#8
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            BaseComponent t = (BaseComponent)target;

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                m_EditorResourceMode.boolValue = EditorGUILayout.BeginToggleGroup("Editor Resource Mode", m_EditorResourceMode.boolValue);
                {
                    EditorGUILayout.HelpBox("Editor resource mode option is only for editor mode. Game Framework will use editor resource files, which you should validate first.", MessageType.Warning);
                    EditorGUILayout.PropertyField(m_EditorLanguage);
                    EditorGUILayout.HelpBox("Editor language option is only use for localization test in editor mode.", MessageType.Info);
                }
                EditorGUILayout.EndToggleGroup();

                EditorGUILayout.BeginVertical("box");
                {
                    EditorGUILayout.LabelField("Global Helpers", EditorStyles.boldLabel);

                    int versionHelperSelectedIndex = EditorGUILayout.Popup("Version Helper", m_VersionHelperTypeNameIndex, m_VersionHelperTypeNames);
                    if (versionHelperSelectedIndex != m_VersionHelperTypeNameIndex)
                    {
                        m_VersionHelperTypeNameIndex        = versionHelperSelectedIndex;
                        m_VersionHelperTypeName.stringValue = (versionHelperSelectedIndex <= 0 ? null : m_VersionHelperTypeNames[versionHelperSelectedIndex]);
                    }

                    int logHelperSelectedIndex = EditorGUILayout.Popup("Log Helper", m_LogHelperTypeNameIndex, m_LogHelperTypeNames);
                    if (logHelperSelectedIndex != m_LogHelperTypeNameIndex)
                    {
                        m_LogHelperTypeNameIndex        = logHelperSelectedIndex;
                        m_LogHelperTypeName.stringValue = (logHelperSelectedIndex <= 0 ? null : m_LogHelperTypeNames[logHelperSelectedIndex]);
                    }

                    int zipHelperSelectedIndex = EditorGUILayout.Popup("Zip Helper", m_ZipHelperTypeNameIndex, m_ZipHelperTypeNames);
                    if (zipHelperSelectedIndex != m_ZipHelperTypeNameIndex)
                    {
                        m_ZipHelperTypeNameIndex        = zipHelperSelectedIndex;
                        m_ZipHelperTypeName.stringValue = (zipHelperSelectedIndex <= 0 ? null : m_ZipHelperTypeNames[zipHelperSelectedIndex]);
                    }

                    int jsonHelperSelectedIndex = EditorGUILayout.Popup("JSON Helper", m_JsonHelperTypeNameIndex, m_JsonHelperTypeNames);
                    if (jsonHelperSelectedIndex != m_JsonHelperTypeNameIndex)
                    {
                        m_JsonHelperTypeNameIndex        = jsonHelperSelectedIndex;
                        m_JsonHelperTypeName.stringValue = (jsonHelperSelectedIndex <= 0 ? null : m_JsonHelperTypeNames[jsonHelperSelectedIndex]);
                    }

                    int profilerHelperSelectedIndex = EditorGUILayout.Popup("Profiler Helper", m_ProfilerHelperTypeNameIndex, m_ProfilerHelperTypeNames);
                    if (profilerHelperSelectedIndex != m_ProfilerHelperTypeNameIndex)
                    {
                        m_ProfilerHelperTypeNameIndex        = profilerHelperSelectedIndex;
                        m_ProfilerHelperTypeName.stringValue = (profilerHelperSelectedIndex <= 0 ? null : m_ProfilerHelperTypeNames[profilerHelperSelectedIndex]);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUI.EndDisabledGroup();

            int frameRate = EditorGUILayout.IntSlider("Frame Rate", m_FrameRate.intValue, 1, 120);

            if (frameRate != m_FrameRate.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.FrameRate = frameRate;
                }
                else
                {
                    m_FrameRate.intValue = frameRate;
                }
            }

            EditorGUILayout.BeginVertical("box");
            {
                float gameSpeed         = EditorGUILayout.Slider("Game Speed", m_GameSpeed.floatValue, 0f, 8f);
                int   selectedGameSpeed = GUILayout.SelectionGrid(GetSelectedGameSpeed(gameSpeed), GameSpeedTexts, 5);
                if (selectedGameSpeed >= 0)
                {
                    gameSpeed = GetGameSpeed(selectedGameSpeed);
                }

                if (gameSpeed != m_GameSpeed.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.GameSpeed = gameSpeed;
                    }
                    else
                    {
                        m_GameSpeed.floatValue = gameSpeed;
                    }
                }
            }
            EditorGUILayout.EndVertical();

            bool runInBackground = EditorGUILayout.Toggle("Run in Background", m_RunInBackground.boolValue);

            if (runInBackground != m_RunInBackground.boolValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.RunInBackground = runInBackground;
                }
                else
                {
                    m_RunInBackground.boolValue = runInBackground;
                }
            }

            bool neverSleep = EditorGUILayout.Toggle("Never Sleep", m_NeverSleep.boolValue);

            if (neverSleep != m_NeverSleep.boolValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.NeverSleep = neverSleep;
                }
                else
                {
                    m_NeverSleep.boolValue = neverSleep;
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
    public void DisplayGUI()
    {
        MegaLoftLayerMultiMat layer = (MegaLoftLayerMultiMat)target;

        SetLimits(layer.gameObject);

        MegaShapeLoftEditor.PushCols();

        GUI.color           = Color.white;
        GUI.backgroundColor = layer.paramcol;
        GUI.contentColor    = Color.white;

        EditorGUILayout.BeginVertical("TextArea");

        if (GUILayout.Button("Reset All Curves"))
        {
            layer.InitCurves();
            GUI.changed = true;
            EditorUtility.SetDirty(target);
        }

        layer.LayerName    = EditorGUILayout.TextField(MegaToolTip.LayerName, layer.LayerName);
        layer.LayerEnabled = EditorGUILayout.Toggle(MegaToolTip.Enabled, layer.LayerEnabled);
        layer.paramcol     = EditorGUILayout.ColorField(MegaToolTip.ParamCol, layer.paramcol);

        if (layer.LayerEnabled)
        {
            layer.Lock = EditorGUILayout.Toggle(MegaToolTip.Lock, layer.Lock);

            if (!layer.Lock)
            {
                layer.material  = (Material)EditorGUILayout.ObjectField(MegaToolTip.Material, layer.material, typeof(Material), true);
                layer.layerPath = (MegaShape)EditorGUILayout.ObjectField(MegaToolTip.Path, layer.layerPath, typeof(MegaShape), true);

                if (layer.layerPath && layer.layerPath.splines != null)
                {
                    if (layer.layerPath.splines.Count > 1)
                    {
                        layer.curve = EditorGUILayout.IntSlider(MegaToolTip.Curve, layer.curve, 0, layer.layerPath.splines.Count - 1);
                    }
                    if (layer.curve < 0)
                    {
                        layer.curve = 0;
                    }
                    if (layer.curve > layer.layerPath.splines.Count - 1)
                    {
                        layer.curve = layer.layerPath.splines.Count - 1;
                    }
                }

                layer.pathStart  = EditorGUILayout.Slider(MegaToolTip.Start, layer.pathStart, sl, sh);
                layer.pathLength = EditorGUILayout.Slider(MegaToolTip.Length, layer.pathLength, ll, lh);
                layer.pathDist   = EditorGUILayout.Slider(MegaToolTip.Dist, layer.pathDist, dl, dh);

                EditorGUILayout.BeginVertical("Box");
                layer.offset = EditorGUILayout.Vector3Field("Offset", layer.offset);

                layer.useOffsetX = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseOffsetX, layer.useOffsetX);
                layer.offsetCrvX = EditorGUILayout.CurveField(MegaToolTip.OffsetCrvX, layer.offsetCrvX);
                EditorGUILayout.EndToggleGroup();

                layer.useOffsetY = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseOffsetY, layer.useOffsetY);
                layer.offsetCrvY = EditorGUILayout.CurveField(MegaToolTip.OffsetCrvY, layer.offsetCrvY);
                EditorGUILayout.EndToggleGroup();

                layer.useOffsetZ = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseOffsetZ, layer.useOffsetZ);
                layer.offsetCrvZ = EditorGUILayout.CurveField(MegaToolTip.OffsetCrvZ, layer.offsetCrvZ);
                EditorGUILayout.EndToggleGroup();

                layer.frameMethod = (MegaFrameMethod)EditorGUILayout.EnumPopup("Frame Method", layer.frameMethod);
                layer.useTwistCrv = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseTwist, layer.useTwistCrv);
                layer.twistAmt    = EditorGUILayout.FloatField(MegaToolTip.Twist, layer.twistAmt);
                layer.twistCrv    = EditorGUILayout.CurveField(MegaToolTip.TwistCrv, layer.twistCrv);
                EditorGUILayout.EndToggleGroup();

                //layer.color = EditorGUILayout.ColorField("Color", layer.color);
                //layer.colR = EditorGUILayout.CurveField("Red", layer.colR);
                //layer.colG = EditorGUILayout.CurveField("Green", layer.colG);
                //layer.colB = EditorGUILayout.CurveField("Blue", layer.colB);
                //layer.colA = EditorGUILayout.CurveField("Alpha", layer.colA);

                EditorGUILayout.EndVertical();

                DisplayMaterialSections(layer);

                //layer.showcrossparams = EditorGUILayout.Foldout(layer.showcrossparams, MegaToolTip.CrossParams);	//"Cross Params");
                layer.showcrossparams = MegaFoldOut.Start("Cross Params", layer.showcrossparams, new Color(0.5f, 1.0f, 0.5f));

                if (layer.showcrossparams)
                {
                    //EditorGUILayout.BeginVertical("Box");
                    layer.layerSection = (MegaShape)EditorGUILayout.ObjectField(MegaToolTip.Section, layer.layerSection, typeof(MegaShape), true);

                    if (layer.layerSection && layer.layerSection.splines != null)
                    {
                        if (layer.layerSection.splines.Count > 1)
                        {
                            layer.crosscurve = EditorGUILayout.IntSlider(MegaToolTip.Curve, layer.crosscurve, 0, layer.layerSection.splines.Count - 1);
                            layer.snap       = EditorGUILayout.Toggle(MegaToolTip.Snap, layer.snap);
                        }
                        if (layer.crosscurve < 0)
                        {
                            layer.crosscurve = 0;
                        }
                        if (layer.crosscurve > layer.layerSection.splines.Count - 1)
                        {
                            layer.crosscurve = layer.layerSection.splines.Count - 1;
                        }
                    }

                    //layer.alignCross = EditorGUILayout.Toggle("Align Cross", layer.alignCross);
                    layer.alignCross = EditorGUILayout.Slider("Align Cross", layer.alignCross, 0.0f, 1.0f);
                    layer.crossStart = EditorGUILayout.Slider(MegaToolTip.CrossStart, layer.crossStart, csl, csh);
                    layer.crossEnd   = EditorGUILayout.Slider(MegaToolTip.CrossLength, layer.crossEnd, cll, clh);
                    //layer.crossDist = EditorGUILayout.Slider(MegaToolTip.CrossDist, layer.crossDist, cdl, cdh);	//0.025f, 1.0f);

                    layer.crossRot   = EditorGUILayout.Vector3Field("Cross Rotate", layer.crossRot);
                    layer.crossScale = EditorGUILayout.Vector3Field("Cross Scale", layer.crossScale);
                    layer.pivot      = EditorGUILayout.Vector3Field("Pivot", layer.pivot);
                    //layer.includeknots = EditorGUILayout.Toggle(MegaToolTip.IncludeKnots, layer.includeknots);
                    layer.useCrossScaleCrv = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseCrossScale, layer.useCrossScaleCrv);
                    layer.crossScaleCrv    = EditorGUILayout.CurveField(MegaToolTip.CrossScaleCrv, layer.crossScaleCrv);
                    layer.scaleoff         = EditorGUILayout.Slider(MegaToolTip.CrossOff, layer.scaleoff, -1.0f, 1.0f);
                    layer.sepscale         = EditorGUILayout.Toggle(MegaToolTip.SeperateScale, layer.sepscale);
                    EditorGUILayout.EndToggleGroup();

                    if (layer.sepscale)
                    {
                        layer.useCrossScaleCrvY = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseCrossScaleY, layer.useCrossScaleCrvY);
                        layer.crossScaleCrvY    = EditorGUILayout.CurveField(MegaToolTip.CrossScaleCrvY, layer.crossScaleCrvY);
                        layer.scaleoffY         = EditorGUILayout.Slider(MegaToolTip.CrossOffY, layer.scaleoffY, -1.0f, 1.0f);
                        EditorGUILayout.EndToggleGroup();
                    }

                    //EditorGUILayout.EndVertical();
                }
                MegaFoldOut.End(layer.showcrossparams);

#if false
                //layer.showadvancedparams = EditorGUILayout.Foldout(layer.showadvancedparams, MegaToolTip.AdvancedParams);
                layer.showadvancedparams = MegaFoldOut.Start("Advanced Params", layer.showadvancedparams, new Color(0.5f, 0.5f, 1.0f));

                if (layer.showadvancedparams)
                {
                    //layer.optimize = EditorGUILayout.Toggle("Optimize", layer.optimize);
                    //layer.maxdeviation = EditorGUILayout.Slider("Max Deviation", layer.maxdeviation, 0.0f, 90.0f);
                    layer.flip    = EditorGUILayout.Toggle(MegaToolTip.Flip, layer.flip);
                    layer.snapTop = EditorGUILayout.BeginToggleGroup(MegaToolTip.SnapTop, layer.snapTop);
                    layer.Top     = EditorGUILayout.FloatField(MegaToolTip.Top, layer.Top);
                    EditorGUILayout.EndToggleGroup();

                    layer.snapBottom = EditorGUILayout.BeginToggleGroup(MegaToolTip.SnapBottom, layer.snapBottom);
                    layer.Bottom     = EditorGUILayout.FloatField(MegaToolTip.Bottom, layer.Bottom);
                    EditorGUILayout.EndToggleGroup();


                    layer.clipTop    = EditorGUILayout.BeginToggleGroup(MegaToolTip.ClipTop, layer.clipTop);
                    layer.clipTopVal = EditorGUILayout.FloatField(MegaToolTip.ClipTopVal, layer.clipTopVal);
                    EditorGUILayout.EndToggleGroup();

                    layer.clipBottom    = EditorGUILayout.BeginToggleGroup(MegaToolTip.ClipBottom, layer.clipBottom);
                    layer.clipBottomVal = EditorGUILayout.FloatField(MegaToolTip.ClipBottomVal, layer.clipBottomVal);
                    EditorGUILayout.EndToggleGroup();
                }
                MegaFoldOut.End(layer.showadvancedparams);
#endif

#if false
                //layer.showuvparams = EditorGUILayout.Foldout(layer.showuvparams, MegaToolTip.UVParams);
                layer.showuvparams = MegaFoldOut.Start("UV Params", layer.showuvparams, new Color(1.0f, 0.5f, 0.5f));

                if (layer.showuvparams)
                {
                    //EditorGUILayout.BeginVertical("Box");
                    MegaShapeLoftEditor.PushCols();
                    GUI.color = Color.white;

                    layer.UVOffset = EditorGUILayout.Vector2Field("UV Offset", layer.UVOffset);
                    layer.UVScale  = EditorGUILayout.Vector2Field("UV Scale", layer.UVScale);
                    layer.swapuv   = EditorGUILayout.Toggle(MegaToolTip.SwapUV, layer.swapuv);
                    layer.physuv   = EditorGUILayout.Toggle(MegaToolTip.PhysicalUV, layer.physuv);
                    layer.uvcalcy  = EditorGUILayout.Toggle("Calc Y", layer.uvcalcy);
                    layer.UVOrigin = (MegaLoftUVOrigin)EditorGUILayout.EnumPopup("UV origin", layer.UVOrigin);

                    layer.planarMapping = EditorGUILayout.BeginToggleGroup("Planar", layer.planarMapping);
                    layer.planarAxis    = (MegaAxis)EditorGUILayout.EnumPopup("Axis", layer.planarAxis);
                    //layer.planarWorld = EditorGUILayout.Toggle("World", layer.planarWorld);
                    layer.planarMode = (MegaPlanarMode)EditorGUILayout.EnumPopup("Mode", layer.planarMode);
                    bool lockWorld = EditorGUILayout.Toggle("Lock World", layer.lockWorld);
                    if (lockWorld != layer.lockWorld)
                    {
                        layer.lockWorld = lockWorld;
                        if (lockWorld)
                        {
                            layer.lockedTM = layer.transform.localToWorldMatrix;
                        }
                    }

                    EditorGUILayout.EndToggleGroup();

                    layer.sideViewUV   = EditorGUILayout.BeginToggleGroup("Side View", layer.sideViewUV);
                    layer.sideViewAxis = (MegaAxis)EditorGUILayout.EnumPopup("Side Axis", layer.sideViewAxis);
                    EditorGUILayout.EndToggleGroup();
                    MegaShapeLoftEditor.PopCols();
                    //EditorGUILayout.EndVertical();
                }
                MegaFoldOut.End(layer.showuvparams);
#endif

#if false
                //layer.showCapParams = EditorGUILayout.Foldout(layer.showCapParams, MegaToolTip.CapParams);
                layer.showCapParams = MegaFoldOut.Start("Cap Params", layer.showCapParams, new Color(1.0f, 1.0f, 0.5f));

                if (layer.showCapParams)
                {
                    layer.capflip          = EditorGUILayout.Toggle("Flip Caps", layer.capflip);
                    layer.capStart         = EditorGUILayout.BeginToggleGroup(MegaToolTip.CapStart, layer.capStart);
                    layer.capStartMat      = (Material)EditorGUILayout.ObjectField(MegaToolTip.CapStartMat, layer.capStartMat, typeof(Material), true);
                    layer.capStartUVOffset = EditorGUILayout.Vector2Field("UV Offset", layer.capStartUVOffset);
                    layer.capStartUVScale  = EditorGUILayout.Vector2Field("UV Scale", layer.capStartUVScale);
                    layer.capStartUVRot    = EditorGUILayout.FloatField(MegaToolTip.CapStartRot, layer.capStartUVRot);

                    EditorGUILayout.EndToggleGroup();

                    layer.capEnd         = EditorGUILayout.BeginToggleGroup(MegaToolTip.CapEnd, layer.capEnd);
                    layer.capEndMat      = (Material)EditorGUILayout.ObjectField(MegaToolTip.CapEndMat, layer.capEndMat, typeof(Material), true);
                    layer.capEndUVOffset = EditorGUILayout.Vector2Field("UV Offset", layer.capEndUVOffset);
                    layer.capEndUVScale  = EditorGUILayout.Vector2Field("UV Scale", layer.capEndUVScale);
                    layer.capEndUVRot    = EditorGUILayout.FloatField(MegaToolTip.CapEndRot, layer.capEndUVRot);
                    EditorGUILayout.EndToggleGroup();
                }
                MegaFoldOut.End(layer.showCapParams);
#endif
                layer.showConformParams = MegaFoldOut.Start("Conform Params", layer.showConformParams, new Color(1.0f, 1.0f, 0.5f));

                if (layer.showConformParams)
                {
                    layer.conform = EditorGUILayout.BeginToggleGroup("Conform", layer.conform);
                    GameObject contarget = (GameObject)EditorGUILayout.ObjectField("Target", layer.target, typeof(GameObject), true);

                    if (contarget != layer.target)
                    {
                        layer.SetTarget(contarget);
                    }
                    layer.conformAmount = EditorGUILayout.Slider("Amount", layer.conformAmount, 0.0f, 1.0f);
                    layer.raystartoff   = EditorGUILayout.FloatField("Ray Start Off", layer.raystartoff);
                    layer.conformOffset = EditorGUILayout.FloatField("Conform Offset", layer.conformOffset);
                    layer.raydist       = EditorGUILayout.FloatField("Ray Dist", layer.raydist);
                    EditorGUILayout.EndToggleGroup();
                }

                MegaFoldOut.End(layer.showConformParams);
            }
        }

        EditorGUILayout.EndVertical();
        MegaShapeLoftEditor.PopCols();
    }
示例#10
0
    void OnGUI()
    {
        GUILayout.Label("Criador de Cartas", EditorStyles.boldLabel);

        /*
         * cardPack = EditorGUILayout.ObjectField ("Card Pack", cardPack, typeof(GameObject), true) as GameObject;
         * card = EditorGUILayout.ObjectField ("Card", card, typeof(GameObject), false) as GameObject;
         * titleObject = EditorGUILayout.ObjectField ("Title", titleObject, typeof(GameObject), false) as GameObject;
         * descriptionObject = EditorGUILayout.ObjectField ("Description", descriptionObject, typeof(GameObject), false) as GameObject;
         * resolutionObject = EditorGUILayout.ObjectField ("Resolution", resolutionObject, typeof(GameObject), false) as GameObject;
         * authorObject = EditorGUILayout.ObjectField ("Author Object", authorObject, typeof(GameObject), false) as GameObject;
         * authorTextObject = EditorGUILayout.ObjectField ("Author", authorTextObject, typeof(GameObject), false) as GameObject;
         */

        cardTitle = EditorGUILayout.TextField("Título", cardTitle);
        EditorGUILayout.Separator();
        cardPicture = EditorGUILayout.ObjectField("Ilustração", cardPicture, typeof(Sprite), true) as Sprite;
        EditorGUILayout.Separator();
        cardDescription = EditorGUILayout.TextField("Enigma", cardDescription, GUILayout.Height(Screen.height / 10));
        cardResolution  = EditorGUILayout.TextField("História", cardResolution, GUILayout.Height(Screen.height / 6));

        checkAuthor = EditorGUILayout.BeginToggleGroup("Inserir autor?", checkAuthor);
        cardAuthor  = EditorGUILayout.TextField("Nome do autor", cardAuthor);
        EditorGUILayout.EndToggleGroup();

        if (GUILayout.Button("Criar"))
        {
            titleObject.GetComponent <Text> ().text       = cardTitle;
            pictureObject.GetComponent <Image> ().sprite  = cardPicture;
            descriptionObject.GetComponent <Text> ().text = cardDescription;
            resolutionObject.GetComponent <Text> ().text  = cardResolution;

            if (checkAuthor)
            {
                authorObject.SetActive(true);
                authorTextObject.SetActive(true);
                authorTextObject.GetComponent <Text> ().text = cardAuthor;
            }
            else
            {
                authorObject.SetActive(false);
                authorTextObject.SetActive(false);
            }

            instCard = Instantiate(card, spawnPoint, Quaternion.identity, cardPack.transform);
            if (cardTitle != "")
            {
                instCard.name = cardTitle;
            }
        }

        if (GUILayout.Button("Limpar"))
        {
            cardTitle       = null;
            cardPicture     = null;
            cardDescription = null;
            cardResolution  = null;
            checkAuthor     = false;
            cardAuthor      = null;
        }
    }
示例#11
0
    // ReSharper disable once FunctionComplexityOverflow
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        EditorGUI.indentLevel = 1;
        var isDirty = false;

        _variation = (DynamicGroupVariation)target;

        if (MasterAudioInspectorResources.LogoTexture != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.LogoTexture);
        }

        EditorGUI.indentLevel = 0;  // Space will handle this for the header
        var previewLang = SystemLanguage.English;

        if (_variation.transform.parent != null && _variation.transform.parent.parent != null)
        {
            var parentParent = _variation.transform.parent.parent;

            _previewer = parentParent.gameObject;

            var dgsc = _previewer.GetComponent <DynamicSoundGroupCreator>();
            if (dgsc != null)
            {
                previewLang = dgsc.previewLanguage;
            }
        }

        if (_previewer == null)
        {
            DTGUIHelper.ShowRedError("This prefab must have a GameObject 2 parents up. Prefab broken.");
            return;
        }

        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUI.contentColor = DTGUIHelper.BrightButtonColor;
        if (GUILayout.Button(new GUIContent("Back to Group", "Select Group in Hierarchy"), EditorStyles.toolbarButton, GUILayout.Width(120)))
        {
            // ReSharper disable once PossibleNullReferenceException
            Selection.activeObject = _variation.transform.parent.gameObject;
        }
        GUILayout.FlexibleSpace();
        GUI.contentColor = Color.white;

        if (!DTGUIHelper.IsPrefabInProjectView(_variation))
        {
            var buttonPressed = DTGUIHelper.AddDynamicVariationButtons();

            switch (buttonPressed)
            {
            case DTGUIHelper.DTFunctionButtons.Play:
                isDirty = true;
                var calcVolume = _variation.VarAudio.volume * _variation.ParentGroup.groupMasterVolume;

                switch (_variation.audLocation)
                {
                case MasterAudio.AudioLocation.ResourceFile:
                    StopPreviewer();
                    var fileName = AudioResourceOptimizer.GetLocalizedDynamicSoundGroupFileName(previewLang,
                                                                                                _variation.useLocalization, _variation.resourceFileName);

                    var clip = Resources.Load(fileName) as AudioClip;
                    if (clip != null)
                    {
                        GetPreviewer().PlayOneShot(clip, calcVolume);
                    }
                    else
                    {
                        DTGUIHelper.ShowAlert("Could not find Resource file: " + fileName);
                    }
                    break;

                case MasterAudio.AudioLocation.Clip:
                    _variation.VarAudio.PlayOneShot(_variation.VarAudio.clip, calcVolume);
                    break;

                case MasterAudio.AudioLocation.FileOnInternet:
                    if (!string.IsNullOrEmpty(_variation.internetFileUrl))
                    {
                        Application.OpenURL(_variation.internetFileUrl);
                    }
                    break;
                }
                break;

            case DTGUIHelper.DTFunctionButtons.Stop:
                if (_variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
                {
                    StopPreviewer();
                }
                else
                {
                    _variation.VarAudio.Stop();
                }
                break;
            }
        }

        EditorGUILayout.EndHorizontal();

        if (!Application.isPlaying)
        {
            DTGUIHelper.ShowColorWarning(MasterAudio.PreviewText);
        }

        var oldLocation = _variation.audLocation;
        var newLocation = (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Audio Origin", _variation.audLocation);

        if (newLocation != oldLocation)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Audio Origin");
            _variation.audLocation = newLocation;
        }

        switch (_variation.audLocation)
        {
        case MasterAudio.AudioLocation.Clip:
            var newClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", _variation.VarAudio.clip, typeof(AudioClip), false);

            if (newClip != _variation.VarAudio.clip)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "assign Audio Clip");
                _variation.VarAudio.clip = newClip;
            }
            break;

        case MasterAudio.AudioLocation.FileOnInternet:
            if (oldLocation != _variation.audLocation)
            {
                if (_variation.VarAudio.clip != null)
                {
                    Debug.Log("Audio clip removed to prevent unnecessary memory usage on File On Internet Variation.");
                }
                _variation.VarAudio.clip = null;
            }

            if (!Application.isPlaying)
            {
                var newUrl = EditorGUILayout.TextField("Internet File URL", _variation.internetFileUrl);
                if (newUrl != _variation.internetFileUrl)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Internet File URL");
                    _variation.internetFileUrl = newUrl;
                }
            }

            if (string.IsNullOrEmpty(_variation.internetFileUrl))
            {
                DTGUIHelper.ShowLargeBarAlert("You have not specified a URL for the File On Internet. This Variation will not be available to play without one.");
            }
            break;

        case MasterAudio.AudioLocation.ResourceFile:
            if (oldLocation != _variation.audLocation)
            {
                if (_variation.VarAudio.clip != null)
                {
                    Debug.Log("Audio clip removed to prevent unnecessary memory usage on Resource file Variation.");
                }
                _variation.VarAudio.clip = null;
            }

            EditorGUILayout.BeginVertical();
            var anEvent = Event.current;

            GUI.color = DTGUIHelper.DragAreaColor;
            var dragArea = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true));
            GUI.Box(dragArea, "Drag Resource Audio clip here to use its name!");
            GUI.color = Color.white;

            string newFilename;

            switch (anEvent.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!dragArea.Contains(anEvent.mousePosition))
                {
                    break;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (anEvent.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();

                    foreach (var dragged in DragAndDrop.objectReferences)
                    {
                        var aClip = dragged as AudioClip;
                        if (aClip == null)
                        {
                            continue;
                        }

                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Resource filename");

                        var useLocalization = false;
                        newFilename = DTGUIHelper.GetResourcePath(aClip, ref useLocalization);
                        if (string.IsNullOrEmpty(newFilename))
                        {
                            newFilename = aClip.name;
                        }

                        _variation.resourceFileName = newFilename;
                        _variation.useLocalization  = useLocalization;
                        break;
                    }
                }
                Event.current.Use();
                break;
            }
            EditorGUILayout.EndVertical();

            newFilename = EditorGUILayout.TextField("Resource Filename", _variation.resourceFileName);
            if (newFilename != _variation.resourceFileName)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Resource filename");
                _variation.resourceFileName = newFilename;
            }

            EditorGUI.indentLevel = 1;

            var newLocal = EditorGUILayout.Toggle("Use Localized Folder", _variation.useLocalization);
            if (newLocal != _variation.useLocalization)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Localized Folder");
                _variation.useLocalization = newLocal;
            }

            break;
        }

        EditorGUI.indentLevel = 0;

        var newVolume = EditorGUILayout.Slider("Volume", _variation.VarAudio.volume, 0f, 1f);

        if (newVolume != _variation.VarAudio.volume)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "change Volume");
            _variation.VarAudio.volume = newVolume;
        }

        var newPitch = DTGUIHelper.DisplayPitchField(_variation.VarAudio.pitch);

        if (newPitch != _variation.VarAudio.pitch)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "change Pitch");
            _variation.VarAudio.pitch = newPitch;
        }

        if (_variation.ParentGroup.curVariationMode == MasterAudioGroup.VariationMode.LoopedChain)
        {
            DTGUIHelper.ShowLargeBarAlert("Loop Clip is always OFF for Looped Chain Groups");
        }
        else
        {
            var newLoop = EditorGUILayout.Toggle("Loop Clip", _variation.VarAudio.loop);
            if (newLoop != _variation.VarAudio.loop)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "toggle Loop");
                _variation.VarAudio.loop = newLoop;
            }
        }

        var newWeight = EditorGUILayout.IntSlider("Voices (Weight)", _variation.weight, 0, 100);

        if (newWeight != _variation.weight)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Voices (Weight)");
            _variation.weight = newWeight;
        }

        var newFxTailTime = EditorGUILayout.Slider("FX Tail Time", _variation.fxTailTime, 0f, 10f);

        if (newFxTailTime != _variation.fxTailTime)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change FX Tail Time");
            _variation.fxTailTime = newFxTailTime;
        }

        var filterList = new List <string>()
        {
            MasterAudio.NoGroupName,
            "Low Pass",
            "High Pass",
            "Distortion",
            "Chorus",
            "Echo",
            "Reverb"
        };

        var newFilterIndex = EditorGUILayout.Popup("Add Filter Effect", 0, filterList.ToArray());

        switch (newFilterIndex)
        {
        case 1:
            AddFilterComponent(typeof(AudioLowPassFilter));
            break;

        case 2:
            AddFilterComponent(typeof(AudioHighPassFilter));
            break;

        case 3:
            AddFilterComponent(typeof(AudioDistortionFilter));
            break;

        case 4:
            AddFilterComponent(typeof(AudioChorusFilter));
            break;

        case 5:
            AddFilterComponent(typeof(AudioEchoFilter));
            break;

        case 6:
            AddFilterComponent(typeof(AudioReverbFilter));
            break;
        }

        DTGUIHelper.StartGroupHeader();

        var newUseRndPitch = EditorGUILayout.BeginToggleGroup(" Use Random Pitch", _variation.useRandomPitch);

        if (newUseRndPitch != _variation.useRandomPitch)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Pitch");
            _variation.useRandomPitch = newUseRndPitch;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useRandomPitch)
        {
            var newMode = (SoundGroupVariation.RandomPitchMode)EditorGUILayout.EnumPopup("Pitch Compute Mode", _variation.randomPitchMode);
            if (newMode != _variation.randomPitchMode)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Pitch Compute Mode");
                _variation.randomPitchMode = newMode;
            }

            var newPitchMin = DTGUIHelper.DisplayPitchField(_variation.randomPitchMin, "Random Pitch Min");
            if (newPitchMin != _variation.randomPitchMin)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Pitch Min");
                _variation.randomPitchMin = newPitchMin;
                if (_variation.randomPitchMax <= _variation.randomPitchMin)
                {
                    _variation.randomPitchMax = _variation.randomPitchMin;
                }
            }

            var newPitchMax = DTGUIHelper.DisplayPitchField(_variation.randomPitchMax, "Random Pitch Max");
            if (newPitchMax != _variation.randomPitchMax)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Pitch Max");
                _variation.randomPitchMax = newPitchMax;
                if (_variation.randomPitchMin > _variation.randomPitchMax)
                {
                    _variation.randomPitchMin = _variation.randomPitchMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newUseRndVol = EditorGUILayout.BeginToggleGroup(" Use Random Volume", _variation.useRandomVolume);

        if (newUseRndVol != _variation.useRandomVolume)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Volume");
            _variation.useRandomVolume = newUseRndVol;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useRandomVolume)
        {
            var newMode = (SoundGroupVariation.RandomVolumeMode)EditorGUILayout.EnumPopup("Volume Compute Mode", _variation.randomVolumeMode);
            if (newMode != _variation.randomVolumeMode)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Volume Compute Mode");
                _variation.randomVolumeMode = newMode;
            }

            var volMin = 0f;
            if (_variation.randomVolumeMode == SoundGroupVariation.RandomVolumeMode.AddToClipVolume)
            {
                volMin = -1f;
            }

            var newVolMin = DTGUIHelper.DisplayVolumeField(_variation.randomVolumeMin, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, volMin, true, "Random Volume Min");
            if (newVolMin != _variation.randomVolumeMin)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Volume Min");
                _variation.randomVolumeMin = newVolMin;
                if (_variation.randomVolumeMax <= _variation.randomVolumeMin)
                {
                    _variation.randomVolumeMax = _variation.randomVolumeMin;
                }
            }

            var newVolMax = DTGUIHelper.DisplayVolumeField(_variation.randomVolumeMax, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, volMin, true, "Random Volume Max");
            if (newVolMax != _variation.randomVolumeMax)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Volume Max");
                _variation.randomVolumeMax = newVolMax;
                if (_variation.randomVolumeMin > _variation.randomVolumeMax)
                {
                    _variation.randomVolumeMin = _variation.randomVolumeMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newSilence = EditorGUILayout.BeginToggleGroup(" Use Random Delay", _variation.useIntroSilence);

        if (newSilence != _variation.useIntroSilence)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Delay");
            _variation.useIntroSilence = newSilence;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useIntroSilence)
        {
            var newSilenceMin = EditorGUILayout.Slider("Delay Min (sec)", _variation.introSilenceMin, 0f, 100f);
            if (newSilenceMin != _variation.introSilenceMin)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Delay Min (sec)");
                _variation.introSilenceMin = newSilenceMin;
                if (_variation.introSilenceMin > _variation.introSilenceMax)
                {
                    _variation.introSilenceMax = newSilenceMin;
                }
            }

            var newSilenceMax = EditorGUILayout.Slider("Delay Max (sec)", _variation.introSilenceMax, 0f, 100f);
            if (newSilenceMax != _variation.introSilenceMax)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Delay Max (sec)");
                _variation.introSilenceMax = newSilenceMax;
                if (_variation.introSilenceMax < _variation.introSilenceMin)
                {
                    _variation.introSilenceMin = newSilenceMax;
                }
            }
        }
        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newStart = EditorGUILayout.BeginToggleGroup(" Use Random Start Position", _variation.useRandomStartTime);

        if (newStart != _variation.useRandomStartTime)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Start Position");
            _variation.useRandomStartTime = newStart;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useRandomStartTime)
        {
            var newMin = EditorGUILayout.Slider("Start Min (%)", _variation.randomStartMinPercent, 0f, 100f);
            if (newMin != _variation.randomStartMinPercent)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Start Min (%)");
                _variation.randomStartMinPercent = newMin;
                if (_variation.randomStartMaxPercent <= _variation.randomStartMinPercent)
                {
                    _variation.randomStartMaxPercent = _variation.randomStartMinPercent;
                }
            }

            var newMax = EditorGUILayout.Slider("Start Max (%)", _variation.randomStartMaxPercent, 0f, 100f);
            if (newMax != _variation.randomStartMaxPercent)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Start Max (%)");
                _variation.randomStartMaxPercent = newMax;
                if (_variation.randomStartMinPercent > _variation.randomStartMaxPercent)
                {
                    _variation.randomStartMinPercent = _variation.randomStartMaxPercent;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newUseFades = EditorGUILayout.BeginToggleGroup(" Use Custom Fading", _variation.useFades);

        if (newUseFades != _variation.useFades)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Custom Fading");
            _variation.useFades = newUseFades;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useFades)
        {
            var newFadeIn = EditorGUILayout.Slider("Fade In Time (sec)", _variation.fadeInTime, 0f, 10f);
            if (newFadeIn != _variation.fadeInTime)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Fade In Time");
                _variation.fadeInTime = newFadeIn;
            }

            if (_variation.VarAudio.loop)
            {
                DTGUIHelper.ShowColorWarning("Looped clips cannot have a custom fade out.");
            }
            else
            {
                var newFadeOut = EditorGUILayout.Slider("Fade Out time (sec)", _variation.fadeOutTime, 0f, 10f);
                if (newFadeOut != _variation.fadeOutTime)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Fade Out Time");
                    _variation.fadeOutTime = newFadeOut;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();

        if (GUI.changed || isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
示例#12
0
	public override void OnInspectorGUI()
	{
		MegaWire mod = (MegaWire)target;

		undoManager.CheckUndo();

		EditorGUIUtility.LookLikeControls();

		MegaWire.DisableAll = EditorGUILayout.Toggle("Disable All", MegaWire.DisableAll);

		if ( GUILayout.Button("Rebuild") )
		{
			mod.Rebuild = true;
			mod.RebuildWire();
		}

		mod.warmPhysicsTime = EditorGUILayout.FloatField("Warm Physics Time", mod.warmPhysicsTime);
		if ( GUILayout.Button("Run Physics") )
		{
			mod.RunPhysics(mod.warmPhysicsTime);
		}

		if ( GUILayout.Button("Open Select Window") )
		{
		}

		if ( GUILayout.Button("Add Wire") )
		{
			MegaWireConnectionDef last = mod.connections[mod.connections.Count - 1];
			MegaWireConnectionDef cdef = new MegaWireConnectionDef();
			cdef.inOffset = last.inOffset;
			cdef.outOffset = last.outOffset;
			cdef.radius = last.radius;
			mod.connections.Add(cdef);
			mod.RebuildWire();
			mod.Rebuild = true;
		}

		mod.Enabled = EditorGUILayout.Toggle("Enabled", mod.Enabled);

		bool ShowWire = EditorGUILayout.Toggle("Show Wire", mod.ShowWire);
		if ( ShowWire != mod.ShowWire )
		{
			mod.ShowWire = ShowWire;
			mod.SetWireVisible(ShowWire);
		}
		// Lod params
		mod.disableOnDistance = EditorGUILayout.BeginToggleGroup("Disable On Dist", mod.disableOnDistance);
		mod.disableDist = EditorGUILayout.FloatField("Disable Dist", mod.disableDist);
		EditorGUILayout.EndToggleGroup();

		mod.disableOnNotVisible = EditorGUILayout.Toggle("Disable On InVisible", mod.disableOnNotVisible);

		// Physics data
		mod.showphysics = EditorGUILayout.Foldout(mod.showphysics, "Physics Params");

		if ( mod.showphysics )
		{
			EditorGUILayout.BeginVertical("box");

			int points = EditorGUILayout.IntSlider("Masses", mod.points, 2, 20);
			if ( points != mod.points )
			{
				mod.points = points;
				mod.RebuildWire();
			}

			float Mass = EditorGUILayout.FloatField("Mass", mod.Mass);
			if ( Mass != mod.Mass )
			{
				mod.Mass = Mass;
				mod.RebuildWire();
			}

			float massrnd = EditorGUILayout.FloatField("Mass Random", mod.massRand);
			if ( massrnd != mod.massRand )
			{
				mod.massRand = massrnd;
				mod.RebuildWire();
			}

			float spring = EditorGUILayout.FloatField("Spring", mod.spring);
			if ( spring != mod.spring )
			{
				mod.spring = spring;
				mod.RebuildWire();
			}

			float damp = EditorGUILayout.FloatField("Damp", mod.damp);
			if ( damp != mod.damp )
			{
				mod.damp = damp;
				mod.RebuildWire();
			}

			float stretch = EditorGUILayout.FloatField("Stretch", mod.stretch);
			if ( stretch != mod.stretch )
			{
				mod.stretch = stretch;
				mod.ChangeStretch(stretch);
			}

			mod.gravity = EditorGUILayout.Vector3Field("Gravity", mod.gravity);
			mod.airdrag = EditorGUILayout.Slider("Aero Drag", mod.airdrag, 0.0f, 1.0f);

			// These require a rebuild
			bool lencon = EditorGUILayout.Toggle("Length Constraints", mod.lengthConstraints);
			if ( lencon != mod.lengthConstraints )
			{
				mod.lengthConstraints = lencon;
				mod.RebuildWire();
			}

			bool stiff = EditorGUILayout.BeginToggleGroup("Stiff Springs", mod.stiffnessSprings);
			if ( stiff != mod.stiffnessSprings )
			{
				mod.stiffnessSprings = stiff;
				mod.RebuildWire();
			}

			float stiffrate = EditorGUILayout.FloatField("Stiff Rate", mod.stiffrate);
			if ( stiffrate != mod.stiffrate )
			{
				mod.stiffrate = stiffrate;
				mod.RebuildWire();
			}

			float stiffdamp = EditorGUILayout.FloatField("Stiff Damp", mod.stiffdamp);
			if ( stiffdamp != mod.stiffdamp )
			{
				mod.stiffdamp = stiffdamp;
				mod.RebuildWire();
			}
			EditorGUILayout.EndToggleGroup();

			mod.doCollisions = EditorGUILayout.BeginToggleGroup("Do Collisions", mod.doCollisions);
			mod.floor = EditorGUILayout.FloatField("Floor", mod.floor);
			EditorGUILayout.EndToggleGroup();

			mod.showWindParams = EditorGUILayout.Foldout(mod.showWindParams, "Wind Params");
			if ( mod.showWindParams )
			{
				mod.wind = (MegaWireWind)EditorGUILayout.ObjectField("Wind Src", mod.wind, typeof(MegaWireWind), true);
				MegaWire.windDir = EditorGUILayout.Vector3Field("Wind Dir", MegaWire.windDir);
				MegaWire.windFrc = EditorGUILayout.FloatField("Wind Frc", MegaWire.windFrc);
				mod.windEffect = EditorGUILayout.FloatField("Wind Effect", mod.windEffect);
			}

			mod.showPhysicsAdv = EditorGUILayout.Foldout(mod.showPhysicsAdv, "Advanced Params");
			if ( mod.showPhysicsAdv )
			{
				mod.timeStep = EditorGUILayout.FloatField("Time Step", mod.timeStep);
				mod.fudge = EditorGUILayout.FloatField("Time Mult", mod.fudge);
				mod.startTime = EditorGUILayout.FloatField("Start Time", mod.startTime);
				mod.awakeTime = EditorGUILayout.FloatField("Awake Time", mod.awakeTime);
				mod.frameWait = EditorGUILayout.IntField("Frame Wait", mod.frameWait);
				mod.frameNum = EditorGUILayout.IntField("Frame Num", mod.frameNum);

				mod.iters = EditorGUILayout.IntSlider("Constraint Iters", mod.iters, 1, 8);
			}

			EditorGUILayout.EndVertical();
		}

		// Meshing options
		mod.showmeshparams = EditorGUILayout.Foldout(mod.showmeshparams, "Mesh Params");
		if ( mod.showmeshparams )
		{
			EditorGUILayout.BeginVertical("box");

			Material mat = (Material)EditorGUILayout.ObjectField("Material", mod.material, typeof(Material), true);
			if ( mat != mod.material )
			{
				mod.material = mat;
				for ( int i = 0; i < mod.spans.Count; i++ )
				{
					mod.spans[i].renderer.sharedMaterial = mat;
				}
			}
			mod.strandedMesher.sides = EditorGUILayout.IntSlider("Sides", mod.strandedMesher.sides, 2, 32);
			mod.strandedMesher.segments = EditorGUILayout.IntSlider("Segments", mod.strandedMesher.segments, 1, 64);
			mod.strandedMesher.SegsPerUnit = EditorGUILayout.FloatField("Segs Per Unit", mod.strandedMesher.SegsPerUnit);
			mod.strandedMesher.strands = EditorGUILayout.IntSlider("Strands", mod.strandedMesher.strands, 1, 8);
			mod.strandedMesher.offset = EditorGUILayout.FloatField("Offset", mod.strandedMesher.offset);
			mod.strandedMesher.strandRadius = EditorGUILayout.FloatField("Strand Radius", mod.strandedMesher.strandRadius);

			mod.strandedMesher.Twist = EditorGUILayout.FloatField("Twist", mod.strandedMesher.Twist);
			mod.strandedMesher.TwistPerUnit = EditorGUILayout.FloatField("Twist Per Unit", mod.strandedMesher.TwistPerUnit);

			bool genuv = EditorGUILayout.BeginToggleGroup("Gen UV", mod.strandedMesher.genuv);
			if ( genuv != mod.strandedMesher.genuv )
			{
				mod.strandedMesher.genuv = genuv;
				mod.builduvs = true;
			}

			float uvtwist = EditorGUILayout.FloatField("UV Twist", mod.strandedMesher.uvtwist);
			if ( uvtwist != mod.strandedMesher.uvtwist )
			{
				mod.strandedMesher.uvtwist = uvtwist;
				mod.builduvs = true;
			}
			
			float uvtilex = EditorGUILayout.FloatField("UV Tile X", mod.strandedMesher.uvtilex);
			if ( uvtilex != mod.strandedMesher.uvtilex )
			{
				mod.strandedMesher.uvtilex = uvtilex;
				mod.builduvs = true;
			}

			float uvtiley = EditorGUILayout.FloatField("UV Tile Y", mod.strandedMesher.uvtiley);
			if ( uvtiley != mod.strandedMesher.uvtiley )
			{
				mod.strandedMesher.uvtiley = uvtiley;
				mod.builduvs = true;
			}
			EditorGUILayout.EndToggleGroup();

			mod.strandedMesher.linInterp = EditorGUILayout.Toggle("Linear Interp", mod.strandedMesher.linInterp);
			mod.strandedMesher.calcBounds = EditorGUILayout.Toggle("Calc Bounds", mod.strandedMesher.calcBounds);
			mod.strandedMesher.calcTangents = EditorGUILayout.Toggle("Calc Tangents", mod.strandedMesher.calcTangents);
		
			int vcount = mod.GetVertexCount();
			EditorGUILayout.LabelField("Vertex Count: " + vcount);
			EditorGUILayout.EndVertical();
		}

		mod.showconnections = EditorGUILayout.Foldout(mod.showconnections, "Connections");

		if ( mod.showconnections )
		{
			for ( int i = 0; i < mod.connections.Count; i++ )
			{
				MegaWireConnectionDef con = mod.connections[i];
				EditorGUILayout.BeginVertical("box");

				float radius = EditorGUILayout.FloatField("Radius", con.radius);
				if ( radius != con.radius )
				{
					con.radius = radius;
				}

				Vector3 outOffset = EditorGUILayout.Vector3Field("Out Offset", con.outOffset);
				if ( outOffset != con.outOffset )
				{
					con.outOffset = outOffset;

					mod.Rebuild = true;
				}

				Vector3 inOffset = EditorGUILayout.Vector3Field("In Offset", con.inOffset);
				if ( inOffset != con.inOffset )
				{
					con.inOffset = inOffset;
					mod.Rebuild = true;
				}

				if ( GUILayout.Button("Delete") )
				{
					if ( mod.connections.Count > 1 )
					{
						mod.connections.RemoveAt(i);
						mod.RebuildWire();
						mod.Rebuild = true;
					}
				}

				EditorGUILayout.EndVertical();
			}
		}

		bool hidespans = EditorGUILayout.Toggle("Hide Spans", mod.hidespans);
		if ( hidespans != mod.hidespans )
		{
			mod.hidespans = hidespans;
			mod.SetHidden(mod.hidespans);
			EditorApplication.RepaintHierarchyWindow();
		}

		mod.displayGizmo = EditorGUILayout.BeginToggleGroup("Show Gizmos", mod.displayGizmo);
		mod.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", mod.gizmoColor);
		EditorGUILayout.EndToggleGroup();

		mod.showAttach = EditorGUILayout.Foldout(mod.showAttach, "Span Connections");

		if ( mod.showAttach )
		{
			EditorGUILayout.BeginVertical("Box");
			for ( int i = 0; i < mod.spans.Count; i++ )
			{
				if ( i > 0 )
					EditorGUILayout.Separator();

				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Start", GUILayout.MaxWidth(40.0f));
				for ( int c = 0; c < mod.spans[i].connections.Count; c++ )
				{
					bool active = EditorGUILayout.Toggle(mod.spans[i].connections[c].constraints[0].active, GUILayout.MaxWidth(10.0f));
					if ( active != mod.spans[i].connections[c].constraints[0].active )
						mod.spans[i].connections[c].SetEndConstraintActive(0, active, 2.0f);
				}
				EditorGUILayout.EndHorizontal();

				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("End", GUILayout.MaxWidth(40.0f));
				for ( int c = 0; c < mod.spans[i].connections.Count; c++ )
				{
					bool active = EditorGUILayout.Toggle(mod.spans[i].connections[c].constraints[1].active, GUILayout.MaxWidth(10.0f));
					if ( active != mod.spans[i].connections[c].constraints[1].active )
						mod.spans[i].connections[c].SetEndConstraintActive(1, active, 2.0f);
				}
				EditorGUILayout.EndHorizontal();
			}
			EditorGUILayout.EndVertical();
		}

		if ( GUI.changed )
			EditorUtility.SetDirty(target);

		undoManager.CheckDirty();
	}
示例#13
0
    public override void OnInspectorGUI()
    {
        MegaHose mod = (MegaHose)target;

        EditorGUIUtility.LookLikeControls();

        mod.dolateupdate    = EditorGUILayout.Toggle("Do Late Update", mod.dolateupdate);
        mod.InvisibleUpdate = EditorGUILayout.Toggle("Invisible Update", mod.InvisibleUpdate);

        mod.wiretype       = (MegaHoseType)EditorGUILayout.EnumPopup("Wire Type", mod.wiretype);
        mod.segments       = EditorGUILayout.IntField("Segments", mod.segments);
        mod.capends        = EditorGUILayout.Toggle("Cap Ends", mod.capends);
        mod.calcnormals    = EditorGUILayout.Toggle("Calc Normals", mod.calcnormals);
        mod.calctangents   = EditorGUILayout.Toggle("Calc Tangents", mod.calctangents);
        mod.optimize       = EditorGUILayout.Toggle("Optimize", mod.optimize);
        mod.recalcCollider = EditorGUILayout.Toggle("Calc Collider", mod.recalcCollider);

        switch (mod.wiretype)
        {
        case MegaHoseType.Round:
            mod.rnddia   = EditorGUILayout.FloatField("Diameter", mod.rnddia);
            mod.rndsides = EditorGUILayout.IntField("Sides", mod.rndsides);
            mod.rndrot   = EditorGUILayout.FloatField("Rotate", mod.rndrot);
            break;

        case MegaHoseType.Rectangle:
            mod.rectwidth       = EditorGUILayout.FloatField("Width", mod.rectwidth);
            mod.rectdepth       = EditorGUILayout.FloatField("Depth", mod.rectdepth);
            mod.rectfillet      = EditorGUILayout.FloatField("Fillet", mod.rectfillet);
            mod.rectfilletsides = EditorGUILayout.IntField("Fillet Sides", mod.rectfilletsides);
            mod.rectrotangle    = EditorGUILayout.FloatField("Rotate", mod.rectrotangle);
            break;

        case MegaHoseType.DSection:
            mod.dsecwidth       = EditorGUILayout.FloatField("Width", mod.dsecwidth);
            mod.dsecdepth       = EditorGUILayout.FloatField("Depth", mod.dsecdepth);
            mod.dsecrndsides    = EditorGUILayout.IntField("Rnd Sides", mod.dsecrndsides);
            mod.dsecfillet      = EditorGUILayout.FloatField("Fillet", mod.dsecfillet);
            mod.dsecfilletsides = EditorGUILayout.IntField("Fillet Sides", mod.dsecfilletsides);
            mod.dsecrotangle    = EditorGUILayout.FloatField("Rotate", mod.dsecrotangle);
            break;
        }

        mod.uvscale = EditorGUILayout.Vector2Field("UV Scale", mod.uvscale);

        if (GUI.changed)
        {
            mod.updatemesh   = true;
            mod.rebuildcross = true;
        }

        mod.custnode  = (GameObject)EditorGUILayout.ObjectField("Start Object", mod.custnode, typeof(GameObject), true);
        mod.offset    = EditorGUILayout.Vector3Field("Offset", mod.offset);
        mod.rotate    = EditorGUILayout.Vector3Field("Rotate", mod.rotate);
        mod.scale     = EditorGUILayout.Vector3Field("Scale", mod.scale);
        mod.custnode2 = (GameObject)EditorGUILayout.ObjectField("End Object", mod.custnode2, typeof(GameObject), true);
        mod.offset1   = EditorGUILayout.Vector3Field("Offset", mod.offset1);
        mod.rotate1   = EditorGUILayout.Vector3Field("Rotate", mod.rotate1);
        mod.scale1    = EditorGUILayout.Vector3Field("Scale", mod.scale1);

        mod.flexon    = EditorGUILayout.BeginToggleGroup("Flex On", mod.flexon);
        mod.flexstart = EditorGUILayout.Slider("Start", mod.flexstart, 0.0f, 1.0f);
        mod.flexstop  = EditorGUILayout.Slider("Stop", mod.flexstop, 0.0f, 1.0f);

        if (mod.flexstart > mod.flexstop)
        {
            mod.flexstart = mod.flexstop;
        }

        if (mod.flexstop < mod.flexstart)
        {
            mod.flexstop = mod.flexstart;
        }

        mod.flexcycles   = EditorGUILayout.IntField("Cycles", mod.flexcycles);
        mod.flexdiameter = EditorGUILayout.FloatField("Diameter", mod.flexdiameter);

        EditorGUILayout.EndToggleGroup();

        mod.usebulgecurve = EditorGUILayout.BeginToggleGroup("Use Bulge Curve", mod.usebulgecurve);
        mod.bulge         = EditorGUILayout.CurveField("Bulge", mod.bulge);
        mod.bulgeamount   = EditorGUILayout.FloatField("Bulge Amount", mod.bulgeamount);
        mod.bulgeoffset   = EditorGUILayout.FloatField("Bulge Offset", mod.bulgeoffset);

        mod.animatebulge = EditorGUILayout.BeginToggleGroup("Animate", mod.animatebulge);
        mod.bulgespeed   = EditorGUILayout.FloatField("Speed", mod.bulgespeed);
        mod.minbulge     = EditorGUILayout.FloatField("Min", mod.minbulge);
        mod.maxbulge     = EditorGUILayout.FloatField("Max", mod.maxbulge);
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.EndToggleGroup();

        mod.tension1 = EditorGUILayout.FloatField("Tension Start", mod.tension1);
        mod.tension2 = EditorGUILayout.FloatField("Tension End", mod.tension2);

        mod.freecreate  = EditorGUILayout.BeginToggleGroup("Free Create", mod.freecreate);
        mod.noreflength = EditorGUILayout.FloatField("Free Length", mod.noreflength);
        EditorGUILayout.EndToggleGroup();

        mod.up            = EditorGUILayout.Vector3Field("Up", mod.up);
        mod.displayspline = EditorGUILayout.Toggle("Display Spline", mod.displayspline);

        if (GUI.changed)                //rebuild )
        {
            mod.updatemesh = true;
            mod.Rebuild();
        }
    }
示例#14
0
    public override bool Inspector()
    {
        MegaDynamicRipple mod = (MegaDynamicRipple)target;

#if !UNITY_5 && !UNITY_2017 && !UNITY_2018 && !UNITY_2019 && !UNITY_2020
        EditorGUIUtility.LookLikeControls();
#endif

        bool dirty = false;
        mod.axis = (MegaAxis)EditorGUILayout.EnumPopup("Axis", mod.axis);

        mod.cols = EditorGUILayout.IntField("Columns", mod.cols);
        if (mod.cols < 1)
        {
            mod.cols = 1;
        }

        mod.rows = EditorGUILayout.IntField("Rows", mod.rows);
        if (mod.rows < 1)
        {
            mod.rows = 1;
        }

        if (GUI.changed)
        {
            dirty = true;
        }

        mod.damping   = EditorGUILayout.Slider("Damping", mod.damping, 0.0f, 1.0f);
        mod.inputdamp = EditorGUILayout.Slider("Input Damping", mod.inputdamp, 0.0f, 1.0f);
        mod.scale     = EditorGUILayout.Slider("Scale", mod.scale, 0.0f, 4.0f);

        mod.speed = EditorGUILayout.Slider("Speed", mod.speed, 0.0f, 0.5f);

        mod.Force = EditorGUILayout.FloatField("Force", mod.Force);

        mod.InputForce = EditorGUILayout.FloatField("InputForce", mod.InputForce);

        mod.Obstructions = EditorGUILayout.BeginToggleGroup("Obstructions", mod.Obstructions);
        bool bilin = EditorGUILayout.Toggle("Bilinear Sample", mod.bilinearSample);
        if (bilin != mod.bilinearSample)
        {
            mod.bilinearSample = bilin;
            dirty = true;
        }
        Texture2D obtex = (Texture2D)EditorGUILayout.ObjectField("Obstructions", mod.obTexture, typeof(Texture2D), true);
        EditorGUILayout.EndToggleGroup();
        if (obtex != mod.obTexture)
        {
            mod.obTexture = obtex;
            dirty         = true;
        }

        mod.DropsPerSec = EditorGUILayout.FloatField("Drops Per Sec", mod.DropsPerSec);
        if (mod.DropsPerSec < 0.0f)
        {
            mod.DropsPerSec = 0.0f;
        }

        if (dirty)
        {
            mod.ResetGrid();
        }

        if (GUILayout.Button("Reset Physics"))
        {
            mod.ResetGrid();
        }

        return(false);
    }
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        EditorGUI.indentLevel = 0;
        var isDirty = false;

        MasterAudio ma = MasterAudio.Instance;

        if (ma == null)
        {
            isValid = false;
        }

        MasterAudioGroup _group = (MasterAudioGroup)target;

        _group = RescanChildren(_group);

        if (!isValid)
        {
            return;
        }

        var isInProjectView = DTGUIHelper.IsPrefabInProjectView(_group);

        if (MasterAudioInspectorResources.logoTexture != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.logoTexture);
        }

        var newVol = EditorGUILayout.Slider("Group Master Volume", _group.groupMasterVolume, 0f, 1f);

        if (newVol != _group.groupMasterVolume)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Group Master Volume");
            _group.groupMasterVolume = newVol;
        }

        var newVarSequence = (MasterAudioGroup.VariationSequence)EditorGUILayout.EnumPopup("Variation Sequence", _group.curVariationSequence);

        if (newVarSequence != _group.curVariationSequence)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Variation Sequence");
            _group.curVariationSequence = newVarSequence;
        }

        if (_group.curVariationSequence == MasterAudioGroup.VariationSequence.TopToBottom)
        {
            var newUseInactive = EditorGUILayout.BeginToggleGroup("Refill Variation Pool After Inactive Time", _group.useInactivePeriodPoolRefill);
            if (newUseInactive != _group.useInactivePeriodPoolRefill)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Inactive Refill");
                _group.useInactivePeriodPoolRefill = newUseInactive;
            }

            EditorGUI.indentLevel = 1;
            var newInactivePeriod = EditorGUILayout.Slider("Inactive Time (sec)", _group.inactivePeriodSeconds, .2f, 30f);
            if (newInactivePeriod != _group.inactivePeriodSeconds)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Inactive Time");
                _group.inactivePeriodSeconds = newInactivePeriod;
            }

            EditorGUILayout.EndToggleGroup();
        }

        EditorGUI.indentLevel = 0;
        var newVarMode = (MasterAudioGroup.VariationMode)EditorGUILayout.EnumPopup("Variation Mode", _group.curVariationMode);

        if (newVarMode != _group.curVariationMode)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Variation Mode");
            _group.curVariationMode = newVarMode;
        }

        EditorGUI.indentLevel = 1;

        switch (_group.curVariationMode)
        {
        case MasterAudioGroup.VariationMode.Normal:
            var newRetrigger = EditorGUILayout.IntSlider("Retrigger Percentage", _group.retriggerPercentage, 0, 100);
            if (newRetrigger != _group.retriggerPercentage)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Retrigger Percentage");
                _group.retriggerPercentage = newRetrigger;
            }

            var newLimitPoly = EditorGUILayout.Toggle("Limit Polyphony", _group.limitPolyphony);
            if (newLimitPoly != _group.limitPolyphony)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Limit Polyphony");
                _group.limitPolyphony = newLimitPoly;
            }
            if (_group.limitPolyphony)
            {
                int maxVoices = 0;
                for (var i = 0; i < _group.groupVariations.Count; i++)
                {
                    var variation = _group.groupVariations[i];
                    maxVoices += variation.weight;
                }

                var newVoiceLimit = EditorGUILayout.IntSlider("Polyphony Voice Limit", _group.voiceLimitCount, 1, maxVoices);
                if (newVoiceLimit != _group.voiceLimitCount)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Polyphony Voice Limit");
                    _group.voiceLimitCount = newVoiceLimit;
                }
            }

            var newLimitMode = (MasterAudioGroup.LimitMode)EditorGUILayout.EnumPopup("Replay Limit Mode", _group.limitMode);
            if (newLimitMode != _group.limitMode)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Replay Limit Mode");
                _group.limitMode = newLimitMode;
            }

            switch (_group.limitMode)
            {
            case MasterAudioGroup.LimitMode.FrameBased:
                var newFrameLimit = EditorGUILayout.IntSlider("Min Frames Between", _group.limitPerXFrames, 1, 120);
                if (newFrameLimit != _group.limitPerXFrames)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Min Frames Between");
                    _group.limitPerXFrames = newFrameLimit;
                }
                break;

            case MasterAudioGroup.LimitMode.TimeBased:
                var newMinTime = EditorGUILayout.Slider("Min Seconds Between", _group.minimumTimeBetween, 0.1f, 10f);
                if (newMinTime != _group.minimumTimeBetween)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Min Seconds Between");
                    _group.minimumTimeBetween = newMinTime;
                }
                break;
            }
            break;

        case MasterAudioGroup.VariationMode.LoopedChain:
            DTGUIHelper.ShowColorWarning("*In this mode, only one Variation can be played at a time.");

            var newLoopMode = (MasterAudioGroup.ChainedLoopLoopMode)EditorGUILayout.EnumPopup("Loop Mode", _group.chainLoopMode);
            if (newLoopMode != _group.chainLoopMode)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Loop Mode");
                _group.chainLoopMode = newLoopMode;
            }

            if (_group.chainLoopMode == MasterAudioGroup.ChainedLoopLoopMode.NumberOfLoops)
            {
                var newLoopCount = EditorGUILayout.IntSlider("Number of Loops", _group.chainLoopNumLoops, 1, 500);
                if (newLoopCount != _group.chainLoopNumLoops)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Number of Loops");
                    _group.chainLoopNumLoops = newLoopCount;
                }
            }

            var newDelayMin = EditorGUILayout.Slider("Clip Change Delay Min", _group.chainLoopDelayMin, 0f, 20f);
            if (newDelayMin != _group.chainLoopDelayMin)
            {
                if (_group.chainLoopDelayMax < newDelayMin)
                {
                    _group.chainLoopDelayMax = newDelayMin;
                }
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Chained Clip Delay Min");
                _group.chainLoopDelayMin = newDelayMin;
            }

            var newDelayMax = EditorGUILayout.Slider("Clip Change Delay Max", _group.chainLoopDelayMax, 0f, 20f);
            if (newDelayMax != _group.chainLoopDelayMax)
            {
                if (newDelayMax < _group.chainLoopDelayMin)
                {
                    newDelayMax = _group.chainLoopDelayMin;
                }
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Chained Clip Delay Max");
                _group.chainLoopDelayMax = newDelayMax;
            }
            break;

        case MasterAudioGroup.VariationMode.Dialog:
            DTGUIHelper.ShowColorWarning("*In this mode, only one Variation can be played at a time.");

            var newUseDialog = EditorGUILayout.Toggle("Dialog Custom Fade?", _group.useDialogFadeOut);
            if (newUseDialog != _group.useDialogFadeOut)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Dialog Custom Fade?");
                _group.useDialogFadeOut = newUseDialog;
            }

            if (_group.useDialogFadeOut)
            {
                var newFadeTime = EditorGUILayout.Slider("Custom Fade Out Time", _group.dialogFadeOutTime, 0.1f, 20f);
                if (newFadeTime != _group.dialogFadeOutTime)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Custom Fade Out Time");
                    _group.dialogFadeOutTime = newFadeTime;
                }
            }
            break;
        }

        EditorGUI.indentLevel = 0;
        if (MasterAudio.Instance.prioritizeOnDistance)
        {
            var newContinual = EditorGUILayout.Toggle("Use Clip Age Priority", _group.useClipAgePriority);
            if (newContinual != _group.useClipAgePriority)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Use Clip Age Priority");
                _group.useClipAgePriority = newContinual;
            }
        }

        var newBulkMode = (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Variation Create Mode", _group.bulkVariationMode);

        if (newBulkMode != _group.bulkVariationMode)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Bulk Variation Mode");
            _group.bulkVariationMode = newBulkMode;
        }
        if (_group.bulkVariationMode == MasterAudio.AudioLocation.ResourceFile)
        {
            DTGUIHelper.ShowColorWarning("*Resource mode: make sure to drag from Resource folders only.");
        }

        var newLog = EditorGUILayout.Toggle("Log Sounds", _group.logSound);

        if (newLog != _group.logSound)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Log Sounds");
            _group.logSound = newLog;
        }

        int?deadChildIndex = null;

        if (!Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);
            GUILayout.Label("Actions", EditorStyles.wordWrappedLabel, GUILayout.Width(50f));
            GUILayout.Space(96);
            GUI.contentColor = Color.green;
            if (GUILayout.Button(new GUIContent("Equalize Weights", "Reset Weights to one"), EditorStyles.toolbarButton, GUILayout.Width(120)))
            {
                isDirty = true;
                EqualizeWeights(_group);
            }

            GUILayout.Space(10);
            if (GUILayout.Button(new GUIContent("Equalize Variation Volumes"), EditorStyles.toolbarButton, GUILayout.Width(150)))
            {
                EqualizeVariationVolumes(_group.groupVariations);
            }

            GUI.contentColor = Color.white;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Separator();
        }

        if (!Application.isPlaying)
        {
            // new variation settings
            EditorGUILayout.BeginVertical();
            var anEvent = Event.current;

            GUI.color = Color.yellow;

            if (isInProjectView)
            {
                DTGUIHelper.ShowLargeBarAlert("*You are in Project View and cannot create Variations.");
                DTGUIHelper.ShowLargeBarAlert("*Pull this prefab into the Scene to create Variations.");
            }
            else
            {
                var dragArea = GUILayoutUtility.GetRect(0f, 35f, GUILayout.ExpandWidth(true));
                GUI.Box(dragArea, "Drag Audio clips here to create Variations!");

                GUI.color = Color.white;

                switch (anEvent.type)
                {
                case EventType.DragUpdated:
                case EventType.DragPerform:
                    if (!dragArea.Contains(anEvent.mousePosition))
                    {
                        break;
                    }

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                    if (anEvent.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();

                        foreach (var dragged in DragAndDrop.objectReferences)
                        {
                            var aClip = dragged as AudioClip;
                            if (aClip == null)
                            {
                                continue;
                            }

                            CreateVariation(_group, ma, aClip);
                        }
                    }
                    Event.current.Use();
                    break;
                }
            }
            EditorGUILayout.EndVertical();
            // end new variation settings
        }

        if (_group.groupVariations.Count == 0)
        {
            DTGUIHelper.ShowRedError("You currently have no Variations.");
        }
        else
        {
            _group.groupVariations.Sort(delegate(SoundGroupVariation x, SoundGroupVariation y) {
                return(x.name.CompareTo(y.name));
            });

            for (var i = 0; i < _group.groupVariations.Count; i++)
            {
                var variation = _group.groupVariations[i];
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                EditorGUILayout.LabelField(variation.name, EditorStyles.boldLabel);

                GUILayout.FlexibleSpace();

                if (GUILayout.Button(new GUIContent(MasterAudioInspectorResources.gearTexture, "Click to goto Variation"), EditorStyles.toolbarButton, GUILayout.Width(40)))
                {
                    Selection.activeObject = variation;
                }

                if (!Application.isPlaying)
                {
                    if (GUILayout.Button(new GUIContent(MasterAudioInspectorResources.deleteTexture, "Click to delete this Variation"), EditorStyles.toolbarButton, GUILayout.Width(40)))
                    {
                        deadChildIndex = i;
                        isDirty        = true;
                    }
                }

                var buttonPressed = DTGUIHelper.AddVariationButtons();
                switch (buttonPressed)
                {
                case DTGUIHelper.DTFunctionButtons.Play:
                    if (Application.isPlaying)
                    {
                        MasterAudio.PlaySound(_group.name, 1f, null, 0f, variation.name);
                    }
                    else
                    {
                        if (variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
                        {
                            MasterAudio.PreviewerInstance.Stop();
                            MasterAudio.PreviewerInstance.PlayOneShot(Resources.Load(variation.resourceFileName) as AudioClip);
                        }
                        else
                        {
                            variation.audio.Stop();
                            variation.audio.Play();
                        }
                    }
                    break;

                case DTGUIHelper.DTFunctionButtons.Stop:
                    if (Application.isPlaying)
                    {
                        MasterAudio.StopAllOfSound(_group.name);
                    }
                    else
                    {
                        if (variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
                        {
                            MasterAudio.PreviewerInstance.Stop();
                        }
                        else
                        {
                            variation.audio.Stop();
                        }
                    }
                    break;
                }

                EditorGUILayout.EndHorizontal();

                if (!Application.isPlaying)
                {
                    DTGUIHelper.ShowColorWarning("*Fading & random settings are ignored by preview in edit mode.");
                }
                if (variation.audio == null)
                {
                    DTGUIHelper.ShowRedError(string.Format("The Variation: '{0}' has no Audio Source.", variation.name));
                    break;
                }

                var oldLocation = variation.audLocation;
                var newLocation = (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Audio Origin", variation.audLocation);
                if (newLocation != variation.audLocation)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "change Audio Origin");
                    variation.audLocation = newLocation;
                }

                switch (variation.audLocation)
                {
                case MasterAudio.AudioLocation.Clip:
                    var newClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", variation.audio.clip, typeof(AudioClip), false);
                    if (newClip != variation.audio.clip)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation.audio, "change Audio Clip");
                        variation.audio.clip = newClip;
                    }
                    break;

                case MasterAudio.AudioLocation.ResourceFile:
                    if (oldLocation != variation.audLocation)
                    {
                        if (variation.audio.clip != null)
                        {
                            Debug.Log("Audio clip removed to prevent unnecessary memory usage on Resource file Variation.");
                        }
                        variation.audio.clip = null;
                    }

                    EditorGUILayout.BeginVertical();
                    var anEvent = Event.current;

                    GUI.color = Color.yellow;
                    var dragArea = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true));
                    GUI.Box(dragArea, "Drag Resource Audio clip here to use its name!");
                    GUI.color = Color.white;

                    switch (anEvent.type)
                    {
                    case EventType.DragUpdated:
                    case EventType.DragPerform:
                        if (!dragArea.Contains(anEvent.mousePosition))
                        {
                            break;
                        }

                        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                        if (anEvent.type == EventType.DragPerform)
                        {
                            DragAndDrop.AcceptDrag();

                            foreach (var dragged in DragAndDrop.objectReferences)
                            {
                                var aClip = dragged as AudioClip;
                                if (aClip == null)
                                {
                                    continue;
                                }

                                UndoHelper.RecordObjectPropertyForUndo(variation, "change Resource Filename");
                                var resourceFileName = DTGUIHelper.GetResourcePath(aClip);
                                if (string.IsNullOrEmpty(resourceFileName))
                                {
                                    resourceFileName = aClip.name;
                                }

                                variation.resourceFileName = resourceFileName;
                            }
                        }
                        Event.current.Use();
                        break;
                    }
                    EditorGUILayout.EndVertical();

                    var newFilename = EditorGUILayout.TextField("Resource Filename", variation.resourceFileName);
                    if (newFilename != variation.resourceFileName)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Resource Filename");
                        variation.resourceFileName = newFilename;
                    }
                    break;
                }

                var newVolume = EditorGUILayout.Slider("Volume", variation.audio.volume, 0f, 1f);
                if (newVolume != variation.audio.volume)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation.audio, "change Volume");
                    variation.audio.volume = newVolume;
                }

                var newPitch = EditorGUILayout.Slider("Pitch", variation.audio.pitch, -3f, 3f);
                if (newPitch != variation.audio.pitch)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation.audio, "change Pitch");
                    variation.audio.pitch = newPitch;
                }

                var newLoop = EditorGUILayout.Toggle("Loop Clip", variation.audio.loop);
                if (newLoop != variation.audio.loop)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation.audio, "toggle Loop Clip");
                    variation.audio.loop = newLoop;
                }

                EditorUtility.SetDirty(variation.audio);
                EditorUtility.SetDirty(variation);

                var newWeight = EditorGUILayout.IntSlider("Weight (Instances)", variation.weight, 0, 100);
                if (newWeight != variation.weight)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "change Weight");
                    variation.weight = newWeight;
                }

                if (variation.HasActiveFXFilter)
                {
                    var newFxTailTime = EditorGUILayout.Slider("FX Tail Time", variation.fxTailTime, 0f, 10f);
                    if (newFxTailTime != variation.fxTailTime)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change FX Tail Time");
                        variation.fxTailTime = newFxTailTime;
                    }
                }

                var newUseRndPitch = EditorGUILayout.BeginToggleGroup("Use Random Pitch", variation.useRandomPitch);
                if (newUseRndPitch != variation.useRandomPitch)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Random Pitch");
                    variation.useRandomPitch = newUseRndPitch;
                }

                if (variation.useRandomPitch)
                {
                    var newMode = (SoundGroupVariation.RandomPitchMode)EditorGUILayout.EnumPopup("Pitch Compute Mode", variation.randomPitchMode);
                    if (newMode != variation.randomPitchMode)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Pitch Compute Mode");
                        variation.randomPitchMode = newMode;
                    }

                    var newPitchMin = EditorGUILayout.Slider("Random Pitch Min", variation.randomPitchMin, -3f, 3f);
                    if (newPitchMin != variation.randomPitchMin)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Pitch Min");
                        variation.randomPitchMin = newPitchMin;
                        if (variation.randomPitchMax <= variation.randomPitchMin)
                        {
                            variation.randomPitchMax = variation.randomPitchMin;
                        }
                    }

                    var newPitchMax = EditorGUILayout.Slider("Random Pitch Max", variation.randomPitchMax, -3f, 3f);
                    if (newPitchMax != variation.randomPitchMax)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Pitch Max");
                        variation.randomPitchMax = newPitchMax;
                        if (variation.randomPitchMin > variation.randomPitchMax)
                        {
                            variation.randomPitchMin = variation.randomPitchMax;
                        }
                    }
                }

                EditorGUILayout.EndToggleGroup();

                var newUseRndVol = EditorGUILayout.BeginToggleGroup("Use Random Volume", variation.useRandomVolume);
                if (newUseRndVol != variation.useRandomVolume)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Random Volume");
                    variation.useRandomVolume = newUseRndVol;
                }

                if (variation.useRandomVolume)
                {
                    var newMode = (SoundGroupVariation.RandomVolumeMode)EditorGUILayout.EnumPopup("Volume Compute Mode", variation.randomVolumeMode);
                    if (newMode != variation.randomVolumeMode)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Volume Compute Mode");
                        variation.randomVolumeMode = newMode;
                    }

                    var volMin = 0f;
                    if (variation.randomVolumeMode == SoundGroupVariation.RandomVolumeMode.AddToClipVolume)
                    {
                        volMin = -1f;
                    }

                    var newVolMin = EditorGUILayout.Slider("Random Volume Min", variation.randomVolumeMin, volMin, 1f);
                    if (newVolMin != variation.randomVolumeMin)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Volume Min");
                        variation.randomVolumeMin = newVolMin;
                        if (variation.randomVolumeMax <= variation.randomVolumeMin)
                        {
                            variation.randomVolumeMax = variation.randomVolumeMin;
                        }
                    }

                    var newVolMax = EditorGUILayout.Slider("Random Volume Max", variation.randomVolumeMax, volMin, 1f);
                    if (newVolMax != variation.randomVolumeMax)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Volume Max");
                        variation.randomVolumeMax = newVolMax;
                        if (variation.randomVolumeMin > variation.randomVolumeMax)
                        {
                            variation.randomVolumeMin = variation.randomVolumeMax;
                        }
                    }
                }

                EditorGUILayout.EndToggleGroup();

                var newSilence = EditorGUILayout.BeginToggleGroup("Use Random Delay", variation.useIntroSilence);
                if (newSilence != variation.useIntroSilence)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Random Delay");
                    variation.useIntroSilence = newSilence;
                }

                if (variation.useIntroSilence)
                {
                    var newSilenceMin = EditorGUILayout.Slider("Delay Min (sec)", variation.introSilenceMin, 0f, 100f);
                    if (newSilenceMin != variation.introSilenceMin)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Delay Min (sec)");
                        variation.introSilenceMin = newSilenceMin;
                        if (variation.introSilenceMin > variation.introSilenceMax)
                        {
                            variation.introSilenceMax = newSilenceMin;
                        }
                    }

                    var newSilenceMax = EditorGUILayout.Slider("Delay Max (sec)", variation.introSilenceMax, 0f, 100f);
                    if (newSilenceMax != variation.introSilenceMax)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Delay Max (sec)");
                        variation.introSilenceMax = newSilenceMax;
                        if (variation.introSilenceMax < variation.introSilenceMin)
                        {
                            variation.introSilenceMin = newSilenceMax;
                        }
                    }
                }

                EditorGUILayout.EndToggleGroup();

                var newFades = EditorGUILayout.BeginToggleGroup("Use Custom Fading", variation.useFades);
                if (newFades != variation.useFades)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Custom Fading");
                    variation.useFades = newFades;
                }

                if (variation.useFades)
                {
                    var newFadeIn = EditorGUILayout.Slider("Fade In Time (sec)", variation.fadeInTime, 0f, 10f);
                    if (newFadeIn != variation.fadeInTime)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Fade In Time");
                        variation.fadeInTime = newFadeIn;
                    }

                    var newFadeOut = EditorGUILayout.Slider("Fade Out time (sec)", variation.fadeOutTime, 0f, 10f);
                    if (newFadeOut != variation.fadeOutTime)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Fade Out Time");
                        variation.fadeOutTime = newFadeOut;
                    }
                }
                EditorGUILayout.EndToggleGroup();

                EditorGUILayout.Separator();
            }
        }

        if (deadChildIndex.HasValue)
        {
            var deadVar = _group.groupVariations[deadChildIndex.Value];

            if (deadVar != null)
            {
                // delete variation from Hierarchy
                GameObject.DestroyImmediate(deadVar.gameObject);
            }

            // delete group.
            _group.groupVariations.RemoveAt(deadChildIndex.Value);
        }

        if (GUI.changed || isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
示例#16
0
    public override void OnInspectorGUI()
    {
        t = (AdsIapSettings)target;
        serializedObject = new SerializedObject(t);

#if !UNITY_IOS && !UNITY_ANDROID
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        GUILayout.TextField("PLEASE SWITCH PLATFORM TO iOS OR ANDROID IN THE BUILD SETTINGS");
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        return;
#endif
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("HOW TO\nENABLE\nUNITY ADS", GUILayout.Width(150), GUILayout.Height(50)))
        {
            Application.OpenURL("https://docs.unity3d.com/Manual/UnityAdsUnityIntegration.html");
        }
        if (GUILayout.Button("HOW TO\nENABLE\nIAP", GUILayout.Width(150), GUILayout.Height(50)))
        {
            Application.OpenURL("https://docs.unity3d.com/Manual/UnityIAPSettingUp.html");
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("GET\nADMOB\nSDK", GUILayout.Width(150), GUILayout.Height(50)))
        {
            Application.OpenURL("https://developers.google.com/admob/unity/start");
        }
        if (GUILayout.Button("GET UNITY\n DATA PRIVACY\nPLUGIN", GUILayout.Width(150), GUILayout.Height(50)))
        {
            Application.OpenURL("https://assetstore.unity.com/packages/add-ons/services/unity-data-privacy-plug-in-118922");
        }

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


        IsIAPenabled = EditorGUILayout.BeginToggleGroup(new GUIContent("Enable UnityIAP"), IsIAPenabled);
        EditorGUILayout.EndToggleGroup();

        EnableAdMob = EditorGUILayout.BeginToggleGroup(new GUIContent("Enable AdMob"), EnableAdMob);
        EditorGUILayout.EndToggleGroup();

        EnableUnityAds = EditorGUILayout.BeginToggleGroup(new GUIContent("Enable UnityAds"), EnableUnityAds);
        EditorGUILayout.EndToggleGroup();

        EnableGDPRconsent = EditorGUILayout.BeginToggleGroup(new GUIContent("Enable GDPR consent"), EnableGDPRconsent);
        EditorGUILayout.EndToggleGroup();

#if UNITY_IAP
        GetProperty("isUnityIapSettingOpened").boolValue = EditorGUILayout.Foldout(GetProperty("isUnityIapSettingOpened").boolValue, "Unity IAP");
        if (GetProperty("isUnityIapSettingOpened").boolValue)
        {
            EditorGUILayout.LabelField(new GUIContent("Product ID Consumable", "Please enter your Product ID Consumable"));
            GetProperty("ProductIDConsumable").stringValue = EditorGUILayout.TextArea(GetProperty("ProductIDConsumable").stringValue);
            EditorGUILayout.LabelField(new GUIContent("Reward for purchase"));
            GetProperty("coinsIAPReward").intValue = Int32.Parse(EditorGUILayout.TextArea(GetProperty("coinsIAPReward").intValue.ToString()));
        }
#endif
#if UNITY_ADS || ENABLE_ADMOB
        GetProperty("isUnityAdsSettingOpened").boolValue = EditorGUILayout.Foldout(GetProperty("isUnityAdsSettingOpened").boolValue, "Rewarded video settings");
        if (GetProperty("isUnityAdsSettingOpened").boolValue)
        {
            EditorGUILayout.LabelField(new GUIContent("Reward for watching the video", "Please enter the reward value"));
            GetProperty("coinsAdReward").intValue = Int32.Parse(EditorGUILayout.TextArea(GetProperty("coinsAdReward").intValue.ToString()));
            EditorGUILayout.LabelField(new GUIContent("Delay between ADs watching HH:MM:SS", "Please enter the needed delay"));
            GetProperty("delayBetweenAds").stringValue = EditorGUILayout.TextArea(GetProperty("delayBetweenAds").stringValue);
            EditorGUILayout.LabelField(new GUIContent("Show AD after each \\X\\ level", "Devider for a level number after which AD should be shown"));
            GetProperty("showAdAfterLevel").intValue = Int32.Parse(EditorGUILayout.TextArea(GetProperty("showAdAfterLevel").intValue.ToString()));
        }
#endif
#if ENABLE_ADMOB
        GetProperty("isUnityAdMobSettingOpened").boolValue = EditorGUILayout.Foldout(GetProperty("isUnityAdMobSettingOpened").boolValue, "AdMob Settings");
        if (GetProperty("isUnityAdMobSettingOpened").boolValue)
        {
#if UNITY_ANDROID
            EditorGUILayout.LabelField(new GUIContent("Android AdMob App ID", "Please enter your Android AdMob App ID"));
            GetProperty("adMobAndroidAppID").stringValue = EditorGUILayout.TextArea(GetProperty("adMobAndroidAppID").stringValue);
            EditorGUILayout.LabelField(new GUIContent("Android AdMob Rewarded Unit ID", "Please enter your Android AdMob Rewarded Unit ID"));
            GetProperty("adMobAndroidRewardedID").stringValue = EditorGUILayout.TextArea(GetProperty("adMobAndroidRewardedID").stringValue);
            EditorGUILayout.LabelField(new GUIContent("Android AdMob Interstitial Unit ID", "Please enter your Android AdMob Interstitial Unit ID"));
            GetProperty("adMobAndroidInterstitialID").stringValue = EditorGUILayout.TextArea(GetProperty("adMobAndroidInterstitialID").stringValue);
#endif
#if UNITY_IOS
            EditorGUILayout.LabelField(new GUIContent("IOS AdMob App ID", "Please enter your IOS AdMob App ID"));
            GetProperty("adMobIosAppID").stringValue = EditorGUILayout.TextArea(GetProperty("adMobIosAppID").stringValue);
            EditorGUILayout.LabelField(new GUIContent("IOS AdMob Rewarded Unit ID", "Please enter your IOS AdMob Rewarded Unit ID"));
            GetProperty("adMobIosRewardedID").stringValue = EditorGUILayout.TextArea(GetProperty("adMobIosRewardedID").stringValue);
            EditorGUILayout.LabelField(new GUIContent("IOS AdMob Interstitial Unit ID", "Please enter your IOS AdMob Interstitial Unit ID"));
            GetProperty("adMobIosInterstitialID").stringValue = EditorGUILayout.TextArea(GetProperty("adMobIosInterstitialID").stringValue);
#endif
        }
#endif
        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
        }
    }
    public override void OnInspectorGUI()
    {
        IsOpenOriginInspector = GUILayout.Toggle(IsOpenOriginInspector, new GUIContent("開啟原始面板"));
        if (IsOpenOriginInspector)
        {
            base.OnInspectorGUI();


            GUILayout.Space(20f);
        }

        serializedObject.Update();

        GUILayout.BeginVertical("Box");

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.TipSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("TipSound"),
            "是否啟用開頭音效",
            "開頭音效或開頭配音"
            );

        UEditorGUI.ToogleGroup(
            ref Instance.SceneSounds.CorrectSoundOnOff,
            serializedObject.FindProperty("SceneSounds").FindPropertyRelative("CorrectSound"),
            "是否啟用答對音效",
            "答對音效"
            );


        GUILayout.EndHorizontal();

        GUILayout.Space(20f);

        GUILayout.BeginVertical("Box");

        #region 開頭動畫物件

        Instance.HeaderAnimObj.HeaderAnimObjOnOff = EditorGUILayout.BeginToggleGroup("開頭動畫物件", Instance.HeaderAnimObj.HeaderAnimObjOnOff);

        Instance.HeaderAnimObj.DisableAtTipEnd = GUILayout.Toggle(Instance.HeaderAnimObj.DisableAtTipEnd, new GUIContent("在開頭音效之後是否關閉動畫"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("HeaderAnimObj").FindPropertyRelative("HeaderAnimObjPrefab"), new GUIContent("開頭動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("HeaderAnimObj").FindPropertyRelative("HeaderAnimObjPosition"), new GUIContent("開頭動畫的位置"));
        if (GUILayout.Button("選擇開頭動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.HeaderAnimObj.HeaderAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("開頭動畫位置", obj, (pos) => {
                float x = Mathf.RoundToInt((pos.x * 10f)) / 10f;
                float y = Mathf.RoundToInt((pos.y * 10f)) / 10f;
                Instance.HeaderAnimObj.HeaderAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }

        EditorGUILayout.EndToggleGroup();
        #endregion


        GUILayout.Space(20);


        #region 額外動畫物件
        Instance.EndingAnimObjs.EndingAnimObjOnOff = EditorGUILayout.BeginToggleGroup("額外動畫物件", Instance.EndingAnimObjs.EndingAnimObjOnOff);
        Instance.EndingAnimObjs.ShowInBeginOnOff   = GUILayout.Toggle(Instance.EndingAnimObjs.ShowInBeginOnOff, "是否一開始就顯示圖片");

        EditorGUILayout.PropertyField(serializedObject.FindProperty("EndingAnimObjs").FindPropertyRelative("EndingAnimObjPrefab"), new GUIContent("結束動畫的prefab"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("EndingAnimObjs").FindPropertyRelative("EndingAnimObjPosition"), new GUIContent("結束動畫的位置"));
        if (GUILayout.Button("選擇結束動畫的位置"))
        {
            var es = GameObject.Find("EditorSelector");
            if (es != null)
            {
                DestroyImmediate(es);
            }


            var obj = Instantiate(Instance.EndingAnimObjs.EndingAnimObjPrefab);
            obj.name = "EditorSelector";
            selector.Select("結束動畫位置", obj, (pos) =>
            {
                float x = Mathf.RoundToInt((pos.x * 10f)) / 10f;
                float y = Mathf.RoundToInt((pos.y * 10f)) / 10f;
                Instance.EndingAnimObjs.EndingAnimObjPosition = new Vector2(x, y);
                DestroyImmediate(obj);
            });
        }
        EditorGUILayout.EndToggleGroup();
        #endregion

        GUILayout.EndVertical();

        GUILayout.Space(20f);

        moveItemsFoldout = EditorGUILayout.Foldout(moveItemsFoldout, "選擇題物件資訊");
        if (moveItemsFoldout)
        {
            UEditorGUI.ArrayEditor(serializedObject.FindProperty("clickData"), typeof(ClickData), MoveItem_ArrayEditorMiddle, MoveItem_ArrayEditorTrail);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(Instance);
            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(Instance.gameObject.scene);
        }

        serializedObject.ApplyModifiedProperties();
    }
示例#18
0
    public override void OnInspectorGUI()
    {
        var evt = (iTweenEvent)target;

        values = evt.Values;
        var keys = values.Keys.ToArray();

        foreach (var key in keys)
        {
            propertiesEnabled[key] = true;
            if (typeof(Vector3OrTransform) == EventParamMappings.mappings[evt.type][key])
            {
                var val = new Vector3OrTransform();

                if (null == values[key] || typeof(Transform) == values[key].GetType())
                {
                    if (null == values[key])
                    {
                        val.transform = null;
                    }
                    else
                    {
                        val.transform = (Transform)values[key];
                    }
                    val.selected = Vector3OrTransform.transformSelected;
                }
                else if (typeof(Vector3) == values[key].GetType())
                {
                    val.vector   = (Vector3)values[key];
                    val.selected = Vector3OrTransform.vector3Selected;
                }

                values[key] = val;
            }
            if (typeof(Vector3OrTransformArray) == EventParamMappings.mappings[evt.type][key])
            {
                var val = new Vector3OrTransformArray();

                if (null == values[key] || typeof(Transform[]) == values[key].GetType())
                {
                    if (null == values[key])
                    {
                        val.transformArray = null;
                    }
                    else
                    {
                        val.transformArray = (Transform[])values[key];
                    }
                    val.selected = Vector3OrTransformArray.transformSelected;
                }
                else if (typeof(Vector3[]) == values[key].GetType())
                {
                    val.vectorArray = (Vector3[])values[key];
                    val.selected    = Vector3OrTransformArray.vector3Selected;
                }
                else if (typeof(string) == values[key].GetType())
                {
                    val.pathName = (string)values[key];
                    val.selected = Vector3OrTransformArray.iTweenPathSelected;
                }

                values[key] = val;
            }
        }

        GUILayout.Label(string.Format("iTween Event Editor v{0}", iTweenEvent.VERSION));
        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Name");
        evt.tweenName = EditorGUILayout.TextField(evt.tweenName);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        evt.showIconInInspector = GUILayout.Toggle(evt.showIconInInspector, " Show Icon In Scene");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        evt.playAutomatically = GUILayout.Toggle(evt.playAutomatically, " Play Automatically");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Initial Start Delay (delay begins once the iTweenEvent is played)");
        evt.delay = EditorGUILayout.FloatField(evt.delay);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Event Type");
        evt.type = (iTweenEvent.TweenType)EditorGUILayout.EnumPopup(evt.type);
        GUILayout.EndHorizontal();

        if (evt.type != previousType)
        {
            foreach (var key in EventParamMappings.mappings[evt.type].Keys)
            {
                propertiesEnabled[key] = false;
            }
            evt.Values   = new Dictionary <string, object>();
            previousType = evt.type;
            return;
        }

        var properties = EventParamMappings.mappings[evt.type];

        foreach (var pair in properties)
        {
            var key = pair.Key;

            GUILayout.BeginHorizontal();

            if (EditorGUILayout.BeginToggleGroup(key, propertiesEnabled[key]))
            {
                propertiesEnabled[key] = true;

                GUILayout.BeginVertical();

                if (typeof(string) == pair.Value)
                {
                    values[key] = EditorGUILayout.TextField(values.ContainsKey(key) ? (string)values[key] : "");
                }
                else if (typeof(float) == pair.Value)
                {
                    values[key] = EditorGUILayout.FloatField(values.ContainsKey(key) ? (float)values[key] : 0);
                }
                else if (typeof(int) == pair.Value)
                {
                    values[key] = EditorGUILayout.IntField(values.ContainsKey(key) ? (int)values[key] : 0);
                }
                else if (typeof(bool) == pair.Value)
                {
                    GUILayout.BeginHorizontal();
                    var currentValueString = (values.ContainsKey(key) ? (bool)values[key] : false).ToString();
                    currentValueString = currentValueString.Substring(0, 1).ToUpper() + currentValueString.Substring(1);
                    var index = EditorGUILayout.Popup(trueFalseOptions.IndexOf(currentValueString), trueFalseOptions.ToArray());
                    GUILayout.EndHorizontal();
                    values[key] = bool.Parse(trueFalseOptions[index]);
                }
                else if (typeof(GameObject) == pair.Value)
                {
                    values[key] = EditorGUILayout.ObjectField(values.ContainsKey(key) ? (GameObject)values[key] : null, typeof(GameObject), true);
                }
                else if (typeof(Vector3) == pair.Value)
                {
                    values[key] = EditorGUILayout.Vector3Field("", values.ContainsKey(key) ? (Vector3)values[key] : Vector3.zero);
                }
                else if (typeof(Vector3OrTransform) == pair.Value)
                {
                    if (!values.ContainsKey(key))
                    {
                        values[key] = new Vector3OrTransform();
                    }
                    var val = (Vector3OrTransform)values[key];

                    val.selected = GUILayout.SelectionGrid(val.selected, Vector3OrTransform.choices, 2);

                    if (Vector3OrTransform.vector3Selected == val.selected)
                    {
                        val.vector = EditorGUILayout.Vector3Field("", val.vector);
                    }
                    else
                    {
                        val.transform = (Transform)EditorGUILayout.ObjectField(val.transform, typeof(Transform), true);
                    }
                    values[key] = val;
                }
                else if (typeof(Vector3OrTransformArray) == pair.Value)
                {
                    if (!values.ContainsKey(key))
                    {
                        values[key] = new Vector3OrTransformArray();
                    }
                    var val = (Vector3OrTransformArray)values[key];
                    val.selected = GUILayout.SelectionGrid(val.selected, Vector3OrTransformArray.choices, Vector3OrTransformArray.choices.Length);

                    if (Vector3OrTransformArray.vector3Selected == val.selected)
                    {
                        if (null == val.vectorArray)
                        {
                            val.vectorArray = new Vector3[0];
                        }
                        var elements = val.vectorArray.Length;
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Number of points");
                        elements = EditorGUILayout.IntField(elements);
                        GUILayout.EndHorizontal();
                        if (elements != val.vectorArray.Length)
                        {
                            var resizedArray = new Vector3[elements];
                            val.vectorArray.CopyTo(resizedArray, 0);
                            val.vectorArray = resizedArray;
                        }
                        for (var i = 0; i < val.vectorArray.Length; ++i)
                        {
                            val.vectorArray[i] = EditorGUILayout.Vector3Field("", val.vectorArray[i]);
                        }
                    }
                    else if (Vector3OrTransformArray.transformSelected == val.selected)
                    {
                        if (null == val.transformArray)
                        {
                            val.transformArray = new Transform[0];
                        }
                        var elements = val.transformArray.Length;
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Number of points");
                        elements = EditorGUILayout.IntField(elements);
                        GUILayout.EndHorizontal();
                        if (elements != val.transformArray.Length)
                        {
                            var resizedArray = new Transform[elements];
                            val.transformArray.CopyTo(resizedArray, 0);
                            val.transformArray = resizedArray;
                        }
                        for (var i = 0; i < val.transformArray.Length; ++i)
                        {
                            val.transformArray[i] = (Transform)EditorGUILayout.ObjectField(val.transformArray[i], typeof(Transform), true);
                        }
                    }
                    else if (Vector3OrTransformArray.iTweenPathSelected == val.selected)
                    {
                        var index = 0;
                        var paths = (GameObject.FindObjectsOfType(typeof(iTweenPath)) as iTweenPath[]);
                        if (0 == paths.Length)
                        {
                            val.pathName = "";
                            GUILayout.Label("No paths are defined");
                        }
                        else
                        {
                            for (var i = 0; i < paths.Length; ++i)
                            {
                                if (paths[i].pathName == val.pathName)
                                {
                                    index = i;
                                }
                            }
                            index = EditorGUILayout.Popup(index, (GameObject.FindObjectsOfType(typeof(iTweenPath)) as iTweenPath[]).Select(path => path.pathName).ToArray());

                            val.pathName = paths[index].pathName;
                        }
                    }
                    values[key] = val;
                }
                else if (typeof(iTween.LoopType) == pair.Value)
                {
                    values[key] = EditorGUILayout.EnumPopup(values.ContainsKey(key) ? (iTween.LoopType)values[key] : iTween.LoopType.none);
                }
                else if (typeof(iTween.EaseType) == pair.Value)
                {
                    values[key] = EditorGUILayout.EnumPopup(values.ContainsKey(key) ? (iTween.EaseType)values[key] : iTween.EaseType.linear);
                }
                else if (typeof(AudioSource) == pair.Value)
                {
                    values[key] = (AudioSource)EditorGUILayout.ObjectField(values.ContainsKey(key) ? (AudioSource)values[key] : null, typeof(AudioSource), true);
                }
                else if (typeof(AudioClip) == pair.Value)
                {
                    values[key] = (AudioClip)EditorGUILayout.ObjectField(values.ContainsKey(key) ? (AudioClip)values[key] : null, typeof(AudioClip), true);
                }
                else if (typeof(Color) == pair.Value)
                {
                    values[key] = EditorGUILayout.ColorField(values.ContainsKey(key) ? (Color)values[key] : Color.white);
                }
                else if (typeof(Space) == pair.Value)
                {
                    values[key] = EditorGUILayout.EnumPopup(values.ContainsKey(key) ? (Space)values[key] : Space.Self);
                }

                GUILayout.EndVertical();
            }
            else
            {
                propertiesEnabled[key] = false;
                values.Remove(key);
            }

            EditorGUILayout.EndToggleGroup();
            GUILayout.EndHorizontal();
            EditorGUILayout.Separator();
        }

        keys = values.Keys.ToArray();

        foreach (var key in keys)
        {
            if (values[key] != null && values[key].GetType() == typeof(Vector3OrTransform))
            {
                var val = (Vector3OrTransform)values[key];
                if (Vector3OrTransform.vector3Selected == val.selected)
                {
                    values[key] = val.vector;
                }
                else
                {
                    values[key] = val.transform;
                }
            }
            else if (values[key] != null && values[key].GetType() == typeof(Vector3OrTransformArray))
            {
                var val = (Vector3OrTransformArray)values[key];
                if (Vector3OrTransformArray.vector3Selected == val.selected)
                {
                    values[key] = val.vectorArray;
                }
                else if (Vector3OrTransformArray.transformSelected == val.selected)
                {
                    values[key] = val.transformArray;
                }
                else if (Vector3OrTransformArray.iTweenPathSelected == val.selected)
                {
                    values[key] = val.pathName;
                }
            }
        }

        evt.Values   = values;
        previousType = evt.type;
    }
    public override void OnInspectorGUI()
    {
        myTarget = (EnviroSkyMgr)target;

        if (boxStyle == null)
        {
            boxStyle = new GUIStyle(GUI.skin.box);
            boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
            boxStyle.fontStyle        = FontStyle.Bold;
            boxStyle.alignment        = TextAnchor.UpperLeft;
        }

        if (wrapStyle == null)
        {
            wrapStyle           = new GUIStyle(GUI.skin.label);
            wrapStyle.fontStyle = FontStyle.Normal;
            wrapStyle.wordWrap  = true;
            wrapStyle.alignment = TextAnchor.UpperLeft;
        }

        if (headerStyle == null)
        {
            headerStyle           = new GUIStyle(GUI.skin.label);
            headerStyle.fontStyle = FontStyle.Bold;
            headerStyle.wordWrap  = true;
            headerStyle.alignment = TextAnchor.UpperLeft;
        }


        GUILayout.BeginVertical("Enviro - Sky Manager 2.2.1", boxStyle);
        GUILayout.Space(20);
        EditorGUILayout.LabelField("Welcome to the Enviro Sky Manager! Add Lite and Standard Enviro instances and switch between those. Add third party support components or choose your render pipeline.", wrapStyle);
        GUILayout.EndVertical();

        GUILayout.BeginVertical("", boxStyle);

        myTarget.showSetup = EditorGUILayout.BeginToggleGroup(" Setup", myTarget.showSetup);

        if (myTarget.showSetup)
        {
            //
            GUILayout.BeginVertical("General", boxStyle);
            GUILayout.Space(20);
            myTarget.dontDestroy = EditorGUILayout.ToggleLeft("  Don't Destroy On Load", myTarget.dontDestroy);

            GUILayout.EndVertical();


            GUILayout.BeginVertical("Render Pipeline", boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("Please set your render pipeline here and choose between 'Legacy' and 'LWRP/URP'. Get Enviro Pro if you want to use 'HDRP'.", wrapStyle);
            GUILayout.Space(10);
#if ENVIRO_PRO
            if (myTarget.currentRenderPipeline == EnviroSkyMgr.EnviroRenderPipeline.HDRP)
            {
                GUILayout.Label("Current Render Pipeline:   HDRP", headerStyle);
            }
            else if (myTarget.currentRenderPipeline == EnviroSkyMgr.EnviroRenderPipeline.LWRP)
            {
                GUILayout.Label("Current Render Pipeline:   LWRP/URP", headerStyle);
            }
            else
            {
                GUILayout.Label("Current Render Pipeline:   Legacy", headerStyle);
            }
#else
            if (myTarget.currentRenderPipeline == EnviroSkyMgr.EnviroRenderPipeline.LWRP)
            {
                GUILayout.Label("Current Render Pipeline:   LWRP/URP", headerStyle);
            }
            else
            {
                GUILayout.Label("Current Render Pipeline:   Legacy", headerStyle);
            }
#endif
            GUILayout.Space(10);
#if ENVIRO_PRO
            if (myTarget.currentRenderPipeline != EnviroSkyMgr.EnviroRenderPipeline.HDRP)
            {
                if (GUILayout.Button("Activate HDRP Support"))
                {
                    myTarget.ActivateHDRP();
                    AddDefineSymbol("ENVIRO_HDRP");
                    RemoveDefineSymbol("ENVIRO_LWRP");
                }
            }
#endif
            if (myTarget.currentRenderPipeline != EnviroSkyMgr.EnviroRenderPipeline.LWRP)
            {
                if (GUILayout.Button("Activate LWRP/URP Support"))
                {
                    myTarget.ActivateLWRP();
                    AddDefineSymbol("ENVIRO_LWRP");
                    RemoveDefineSymbol("ENVIRO_HDRP");
                }
            }
            if (myTarget.currentRenderPipeline != EnviroSkyMgr.EnviroRenderPipeline.Legacy)
            {
                if (GUILayout.Button("Activate Legacy Support"))
                {
                    myTarget.ActivateLegacyRP();
                    RemoveDefineSymbol("ENVIRO_LWRP");
                    RemoveDefineSymbol("ENVIRO_HDRP");
                }
            }

            if (myTarget.currentRenderPipeline == EnviroSkyMgr.EnviroRenderPipeline.LWRP)
            {
                GUILayout.BeginVertical("LWRP/URP Setup", boxStyle);
                GUILayout.Space(20);
                EditorGUILayout.LabelField("Please import the files for URP with the 'Import' button. This will import all necesarry files and a preconfigured Renderer. After that you need to assign the 'Enviro URP Renderer' in your URP quality settings as custom renderer.", wrapStyle);
                GUILayout.Space(10);
#if ENVIRO_LW
                if (GUILayout.Button("Import LWRP/URP Support for Enviro Lite"))
                {
                    AssetDatabase.ImportPackage("Assets/Enviro - Sky and Weather/Enviro Lite/URP Support/Enviro_Lite_URP.unitypackage", false);
                }
#endif
#if ENVIRO_HD
                if (GUILayout.Button("Import LWRP/URP Support for Enviro Standard"))
                {
                    AssetDatabase.ImportPackage("Assets/Enviro - Sky and Weather/Enviro Standard/URP Support/Enviro_Standard_URP.unitypackage", false);
                }
#endif
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();

            GUILayout.Space(10);
#if ENVIRO_HD
            GUILayout.BeginVertical("Standard Version", boxStyle);
            GUILayout.Space(20);
            if (myTarget.enviroHDInstance == null)
            {
                if (GUILayout.Button("Create Standard Instance"))
                {
                    myTarget.CreateEnviroHDInstance();
                }
                if (GUILayout.Button("Create Standard VR Instance"))
                {
                    myTarget.CreateEnviroHDVRInstance();
                }
            }
            else
            {
                GUILayout.Label("Current Instance found!", headerStyle);
                GUILayout.Label("Delete " + myTarget.enviroHDInstance.gameObject.name + " if you want to add other prefab!");
            }
            GUILayout.EndVertical();
#endif
#if ENVIRO_LW
            GUILayout.BeginVertical("Lite Version", boxStyle);
            GUILayout.Space(20);
            if (myTarget.enviroLWInstance == null)
            {
                if (GUILayout.Button("Create Lite Instance"))
                {
                    myTarget.CreateEnviroLWInstance();
                }
                if (GUILayout.Button("Create Lite Mobile Instance"))
                {
                    myTarget.CreateEnviroLWMobileInstance();
                }
            }
            else
            {
                GUILayout.Label("Current Instance found!", headerStyle);
                GUILayout.Label("Delete " + myTarget.enviroLWInstance.gameObject.name + " if you want to add other prefab!");
            }
            GUILayout.EndVertical();
#endif
        }
        GUILayout.EndVertical();

        EditorGUILayout.EndToggleGroup();

        GUILayout.BeginVertical("", boxStyle);
        myTarget.showInstances = EditorGUILayout.BeginToggleGroup(" Instances", myTarget.showInstances);
        if (myTarget.showInstances)
        {
            //  GUILayout.Space(10);
#if ENVIRO_HD
            if (myTarget.enviroHDInstance != null)
            {
                if (myTarget.currentEnviroSkyVersion != EnviroSkyMgr.EnviroSkyVersion.HD)
                {
                    GUI.backgroundColor = modifiedColor;
                }
                else
                {
                    if (myTarget.enviroHDInstance.Player == null || myTarget.enviroHDInstance.PlayerCamera == null)
                    {
                        GUI.backgroundColor = modifiedColor;
                    }
                    else
                    {
                        GUI.backgroundColor = greenColor;
                    }
                }

                GUILayout.BeginVertical(myTarget.enviroHDInstance.gameObject.name, boxStyle);
                GUI.backgroundColor = Color.white;
                GUILayout.Space(20);
                if (myTarget.currentEnviroSkyVersion != EnviroSkyMgr.EnviroSkyVersion.HD)
                {
                    if (GUILayout.Button("Activate"))
                    {
                        myTarget.ActivateHDInstance();
                    }
                }
                else if (myTarget.currentEnviroSkyVersion == EnviroSkyMgr.EnviroSkyVersion.HD)
                {
                    if (myTarget.enviroHDInstance.Player == null || myTarget.enviroHDInstance.PlayerCamera == null)
                    {
                        GUILayout.Label("Player and/or camera assignment is missing!");

                        if (GUILayout.Button("Auto Assign"))
                        {
                            myTarget.enviroHDInstance.AssignAndStart(Camera.main.gameObject, Camera.main);
                        }
                    }
                    else
                    {
                        if (Application.isPlaying)
                        {
                            if (!myTarget.enviroHDInstance.started)
                            {
                                if (GUILayout.Button("Play"))
                                {
                                    myTarget.enviroHDInstance.Play(myTarget.enviroHDInstance.GameTime.ProgressTime);
                                }
                            }
                            else
                            {
                                if (GUILayout.Button("Stop"))
                                {
                                    myTarget.enviroHDInstance.Stop(false, true);
                                }
                            }
                        }

                        if (GUILayout.Button("Deactivate"))
                        {
                            myTarget.DeactivateHDInstance();
                        }
                    }
                }

                if (GUILayout.Button("Show"))
                {
                    Selection.activeObject = myTarget.enviroHDInstance;
                }

                if (GUILayout.Button("Delete"))
                {
                    if (EditorUtility.DisplayDialog("Delete Instance?", "Are you sure that you want to delete this instance?", "Delete", "Cancel"))
                    {
                        myTarget.DeleteHDInstance();
                    }
                }

                GUILayout.EndVertical();
            }
#endif

#if ENVIRO_LW
            if (myTarget.enviroLWInstance != null)
            {
                if (myTarget.currentEnviroSkyVersion != EnviroSkyMgr.EnviroSkyVersion.LW)
                {
                    GUI.backgroundColor = modifiedColor;
                }
                else
                {
                    if (myTarget.enviroLWInstance.Player == null || myTarget.enviroLWInstance.PlayerCamera == null)
                    {
                        GUI.backgroundColor = modifiedColor;
                    }
                    else
                    {
                        GUI.backgroundColor = greenColor;
                    }
                }

                GUILayout.BeginVertical(myTarget.enviroLWInstance.gameObject.name, boxStyle);
                GUI.backgroundColor = Color.white;
                GUILayout.Space(20);
                if (myTarget.currentEnviroSkyVersion != EnviroSkyMgr.EnviroSkyVersion.LW)
                {
                    if (GUILayout.Button("Activate"))
                    {
                        myTarget.ActivateLWInstance();
                    }
                }
                else if (myTarget.currentEnviroSkyVersion == EnviroSkyMgr.EnviroSkyVersion.LW)
                {
                    if (myTarget.enviroLWInstance.Player == null || myTarget.enviroLWInstance.PlayerCamera == null)
                    {
                        GUILayout.Label("Player and/or camera assignment is missing!");

                        if (GUILayout.Button("Auto Assign"))
                        {
                            if (Camera.main != null)
                            {
                                myTarget.enviroLWInstance.AssignAndStart(Camera.main.gameObject, Camera.main);
                            }
                        }
                    }
                    else
                    {
                        if (Application.isPlaying)
                        {
                            if (!myTarget.enviroLWInstance.started)
                            {
                                if (GUILayout.Button("Play"))
                                {
                                    myTarget.enviroLWInstance.Play(myTarget.enviroLWInstance.GameTime.ProgressTime);
                                }
                            }
                            else
                            {
                                if (GUILayout.Button("Stop"))
                                {
                                    myTarget.enviroLWInstance.Stop(false, true);
                                }
                            }
                        }
                        if (GUILayout.Button("Deactivate"))
                        {
                            myTarget.DeactivateLWInstance();
                        }
                    }
                }

                if (GUILayout.Button("Show"))
                {
                    Selection.activeObject = myTarget.enviroLWInstance;
                }

                if (GUILayout.Button("Delete"))
                {
                    if (EditorUtility.DisplayDialog("Delete Instance?", "Are you sure that you want to delete this instance?", "Delete", "Cancel"))
                    {
                        myTarget.DeleteLWInstance();
                    }
                }

                GUILayout.EndVertical();
            }
#endif
        }
        GUILayout.EndVertical();
        EditorGUILayout.EndToggleGroup();

        GUILayout.BeginVertical("", boxStyle);
        myTarget.showThirdParty = EditorGUILayout.BeginToggleGroup(" Third Party Support", myTarget.showThirdParty);

        if (myTarget.showThirdParty)
        {
            GUILayout.Space(10);
            GUILayout.BeginVertical("", boxStyle);
            myTarget.showThirdPartyMisc = EditorGUILayout.BeginToggleGroup(" Miscellaneous", myTarget.showThirdPartyMisc);


            if (myTarget.showThirdPartyMisc)
            {
                //WAPI
                GUILayout.BeginVertical("World Manager API", boxStyle);
                GUILayout.Space(20);
#if WORLDAPI_PRESENT
                if (myTarget.gameObject.GetComponent <EnviroWorldAPIIntegration>() == null)
                {
                    if (GUILayout.Button("Add WAPI Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroWorldAPIIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove WAPI Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroWorldAPIIntegration>());
                    }
                }
#else
                EditorGUILayout.LabelField("World Manager API no found!", wrapStyle);
#endif
                GUILayout.EndVertical();

                //Vegetation Studio Pro
                GUILayout.BeginVertical("Vegetation Studio Pro", boxStyle);
                GUILayout.Space(20);
#if VEGETATION_STUDIO_PRO
                if (myTarget.gameObject.GetComponent <EnviroVegetationStudioPro>() == null)
                {
                    if (GUILayout.Button("Add Vegetation Studio Pro Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroVegetationStudioPro>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove Vegetation Studio Pro Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroVegetationStudioPro>());
                    }
                }
#else
                EditorGUILayout.LabelField("Vegetation Studio Pro not found in project!", wrapStyle);
#endif
                GUILayout.EndVertical();


                //PEGASUS
                GUILayout.BeginVertical("Pegasus", boxStyle);
                GUILayout.Space(20);
#if ENVIRO_PEGASUS_SUPPORT
                EditorGUILayout.LabelField("Pegasus support is activated! Please use the new enviro trigger to drive enviro settings with Pegasus.");
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate Pegasus Support"))
                {
                    RemoveDefineSymbol("ENVIRO_PEGASUS_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("Pegasus support not activated! Please activate if you have Pegasus in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate Pegasus Support"))
                {
                    AddDefineSymbol("ENVIRO_PEGASUS_SUPPORT");
                }
                if (GUILayout.Button("Deactivate Pegasus Support"))
                {
                    RemoveDefineSymbol("ENVIRO_PEGASUS_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////


                //FogVolume
                GUILayout.BeginVertical("FogVolume 3", boxStyle);
                GUILayout.Space(20);
#if ENVIRO_FV3_SUPPORT
                if (myTarget.gameObject.GetComponent <EnviroFogVolumeIntegration>() == null)
                {
                    if (GUILayout.Button("Add FogVolume Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroFogVolumeIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove FogVolume Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroFogVolumeIntegration>());
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate FogVolume Support"))
                {
                    RemoveDefineSymbol("ENVIRO_FV3_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("FogVolume3 support not activated! Please activate if you have FogVolume3 package in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate FogVolume Support"))
                {
                    AddDefineSymbol("ENVIRO_FV3_SUPPORT");
                }
                if (GUILayout.Button("Deactivate FogVolume Support"))
                {
                    RemoveDefineSymbol("ENVIRO_FV3_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////
                //Aura 2
                GUILayout.BeginVertical("Aura 2", boxStyle);
                GUILayout.Space(20);
#if AURA_IN_PROJECT
                if (!myTarget.aura2Support)
                {
                    EditorGUILayout.LabelField("Aura 2 support is deactivated!", wrapStyle);
                    if (GUILayout.Button("Activate Aura 2 Support"))
                    {
                        myTarget.aura2Support = true;
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("Aura 2 is active! Please assign your Aura 2 presets in your weather presets! Enviro will change aura preset for you on weather changes then.", wrapStyle);
                    GUILayout.Space(20);
                    GUILayout.BeginVertical("", boxStyle);
                    GUILayout.Space(5);
                    if (myTarget.Components.DirectLight.GetComponent <Aura2API.AuraLight>() == null)
                    {
                        if (GUILayout.Button("Convert Enviro Directional Light to Aura2"))
                        {
                            myTarget.Components.DirectLight.gameObject.AddComponent <Aura2API.AuraLight>();

                            if (myTarget.Components.AdditionalDirectLight != null && myTarget.Components.AdditionalDirectLight.GetComponent <Aura2API.AuraLight>() == null)
                            {
                                myTarget.Components.AdditionalDirectLight.gameObject.AddComponent <Aura2API.AuraLight>();
                            }
                        }
                    }
                    else
                    {
                        myTarget.aura2DirectionalLightIntensity = EditorGUILayout.CurveField("Aura2 Directional Light Strength", myTarget.aura2DirectionalLightIntensity);

                        if (myTarget.Components.AdditionalDirectLight != null)
                        {
                            myTarget.aura2DirectionalLightIntensityMoon = EditorGUILayout.CurveField("Aura2 Directional Light Moon Strength", myTarget.aura2DirectionalLightIntensityMoon);
                        }
                    }
                    if (myTarget.Camera != null && myTarget.Camera.GetComponent <Aura2API.AuraCamera>() == null)
                    {
                        if (GUILayout.Button("Add Aura2 Camera component"))
                        {
                            Aura2API.Aura.AddAuraToCameras();
                        }
                    }
                    else
                    {
                        myTarget.aura2TransitionSpeed = EditorGUILayout.FloatField("Aura2 Transition Speed", myTarget.aura2TransitionSpeed);
                    }
                    GUILayout.Space(5);
                    GUILayout.EndVertical();
                    GUILayout.Space(20);


                    if (GUILayout.Button("Deactivate Aura 2 Support"))
                    {
                        myTarget.aura2Support = false;
                    }
                }
#else
                EditorGUILayout.LabelField("Aura 2 not found in your project.", wrapStyle);
#endif
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndToggleGroup();


            GUILayout.BeginVertical("", boxStyle);
            myTarget.showThirdPartyShaders = EditorGUILayout.BeginToggleGroup(" Shaders", myTarget.showThirdPartyShaders);

            if (myTarget.showThirdPartyShaders)
            {
                //CTS
                GUILayout.BeginVertical("Complete Terrain Shader", boxStyle);
                GUILayout.Space(20);
#if CTS_PRESENT
                if (myTarget.gameObject.GetComponent <EnviroCTSIntegration>() == null)
                {
                    if (GUILayout.Button("Add CTS Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroCTSIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove WAPI Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroCTSIntegration>());
                    }
                }
#else
                EditorGUILayout.LabelField("CTS not found in project!", wrapStyle);
#endif
                GUILayout.EndVertical();


                //MicroSplat
                GUILayout.BeginVertical("MicroSplat", boxStyle);
                GUILayout.Space(20);

#if ENVIRO_MICROSPLAT_SUPPORT
                if (myTarget.gameObject.GetComponent <EnviroMicroSplatIntegration>() == null)
                {
                    if (GUILayout.Button("Add MicroSplat Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroMicroSplatIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove MicroSplat Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroMicroSplatIntegration>());
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate MicroSplat Support"))
                {
                    RemoveDefineSymbol("ENVIRO_MICROSPLAT_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("MicroSplat support not activated! Please activate if you have Microsplat in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate MicroSplat Support"))
                {
                    AddDefineSymbol("ENVIRO_MICROSPLAT_SUPPORT");
                }
                if (GUILayout.Button("Deactivate MicroSplat Support"))
                {
                    RemoveDefineSymbol("ENVIRO_MICROSPLAT_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////

                //MegaSplat
                GUILayout.BeginVertical("MegaSplat", boxStyle);
                GUILayout.Space(20);
#if ENVIRO_MEGASPLAT_SUPPORT
                if (myTarget.gameObject.GetComponent <EnviroMegaSplatIntegration>() == null)
                {
                    if (GUILayout.Button("Add MegaSplat Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroMegaSplatIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove MegaSplat Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroMegaSplatIntegration>());
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate MegaSplat Support"))
                {
                    RemoveDefineSymbol("ENVIRO_MEGASPLAT_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("MegaSplat support not activated! Please activate if you have MegaSplat in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate MegaSplat Support"))
                {
                    AddDefineSymbol("ENVIRO_MEGASPLAT_SUPPORT");
                }
                if (GUILayout.Button("Deactivate MegaSplat Support"))
                {
                    RemoveDefineSymbol("ENVIRO_MEGASPLAT_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////

                //RTP
                GUILayout.BeginVertical("Relief Terrain Shader", boxStyle);
                GUILayout.Space(20);

#if ENVIRO_RTP_SUPPORT
                if (myTarget.gameObject.GetComponent <EnviroRTPIntegration>() == null)
                {
                    if (GUILayout.Button("Add RTP Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroRTPIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove RTP Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroRTPIntegration>());
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate RTP Support"))
                {
                    RemoveDefineSymbol("ENVIRO_RTP_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("Relief Terrain Shader support not activated! Please activate if you have Relief Terrain Shader package in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate RTP Support"))
                {
                    AddDefineSymbol("ENVIRO_RTP_SUPPORT");
                }
                if (GUILayout.Button("Deactivate RTP Support"))
                {
                    RemoveDefineSymbol("ENVIRO_RTP_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////

                //UBER
                GUILayout.BeginVertical("UBER Shaderframework", boxStyle);
                GUILayout.Space(20);

#if ENVIRO_UBER_SUPPORT
                if (myTarget.gameObject.GetComponent <EnviroRTPIntegration>() == null)
                {
                    if (GUILayout.Button("Add UBER Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroRTPIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove UBER Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroRTPIntegration>());
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate UBER Support"))
                {
                    RemoveDefineSymbol("ENVIRO_UBER_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("UBER Shader support not activated! Please activate if you have UBER Shader package in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate UBER Support"))
                {
                    AddDefineSymbol("ENVIRO_UBER_SUPPORT");
                }
                if (GUILayout.Button("Deactivate UBER Support"))
                {
                    RemoveDefineSymbol("ENVIRO_UBER_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////

                //LUX
                GUILayout.BeginVertical("LUX Shaderframework", boxStyle);
                GUILayout.Space(20);

#if ENVIRO_LUX_SUPPORT
                if (myTarget.gameObject.GetComponent <EnviroLUXIntegration>() == null)
                {
                    if (GUILayout.Button("Add LUX Support"))
                    {
                        myTarget.gameObject.AddComponent <EnviroLUXIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove LUX Support"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroLUXIntegration>());
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Deactivate LUX Support"))
                {
                    RemoveDefineSymbol("ENVIRO_LUX_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("LUX Shader support not activated! Please activate if you have LUX Shader package in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate LUX Support"))
                {
                    AddDefineSymbol("ENVIRO_LUX_SUPPORT");
                }
                if (GUILayout.Button("Deactivate LUX Support"))
                {
                    RemoveDefineSymbol("ENVIRO_LUX_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndToggleGroup();


            GUILayout.BeginVertical("", boxStyle);
            myTarget.showThirdPartyNetwork = EditorGUILayout.BeginToggleGroup(" Networking", myTarget.showThirdPartyNetwork);

            if (myTarget.showThirdPartyNetwork)
            {
                //UNET
                GUILayout.BeginVertical("UNet Networking", boxStyle);
                GUILayout.Space(20);
#if ENVIRO_UNET_SUPPORT
                EditorGUILayout.LabelField("UNET support is activated! Please also add the EnviroUNetPlayer component to your players!");

                if (myTarget.gameObject.GetComponent <EnviroUNetServer>() == null)
                {
                    if (GUILayout.Button("Add UNet Integration Component"))
                    {
                        myTarget.gameObject.AddComponent <EnviroUNetServer>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove UNet Integration Component"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroUNetServer>());
                    }
                }
                GUILayout.Space(10);
                if (GUILayout.Button("Deactivate UNet Support"))
                {
                    RemoveDefineSymbol("ENVIRO_UNET_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("UNet support not activated! Please activate if would like to use UNet with Enviro.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate UNet Support"))
                {
                    AddDefineSymbol("ENVIRO_UNET_SUPPORT");
                }
                if (GUILayout.Button("Deactivate UNet Support"))
                {
                    RemoveDefineSymbol("ENVIRO_UNET_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////



                //Mirror
                GUILayout.BeginVertical("Mirror Networking", boxStyle);
                GUILayout.Space(20);
#if ENVIRO_MIRROR_SUPPORT
                EditorGUILayout.LabelField("Mirror support is activated! Please also add the EnviroMirrorPlayer component to your players!");

                if (GameObject.Find("/Enviro Mirror Server") == null)
                {
                    if (GUILayout.Button("Add Mirror Integration Component"))
                    {
                        GameObject mServer = new GameObject();
                        mServer.name = "Enviro Mirror Server";
                        mServer.AddComponent <EnviroMirrorServer>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove Mirror Integration Component"))
                    {
                        if (GameObject.Find("/Enviro Mirror Server") != null)
                        {
                            DestroyImmediate(GameObject.Find("/Enviro Mirror Server"));
                        }
                    }
                }
                GUILayout.Space(10);
                if (GUILayout.Button("Deactivate Mirror Support"))
                {
                    RemoveDefineSymbol("ENVIRO_MIRROR_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("Mirror support not activated! Please activate if would like to use Mirror with Enviro.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate Mirror Support"))
                {
                    AddDefineSymbol("ENVIRO_MIRROR_SUPPORT");
                }
                if (GUILayout.Button("Deactivate Mirror Support"))
                {
                    RemoveDefineSymbol("ENVIRO_MIRROR_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////

                //Photon
                GUILayout.BeginVertical("Photon Networking", boxStyle);
                GUILayout.Space(20);
#if ENVIRO_PHOTON_SUPPORT
                EditorGUILayout.LabelField("Photon PUN 2 support is activated!");

                if (myTarget.gameObject.GetComponent <EnviroPhotonIntegration>() == null)
                {
                    if (GUILayout.Button("Add Photon Integration Component"))
                    {
                        myTarget.gameObject.AddComponent <EnviroPhotonIntegration>();
                    }
                }
                else
                {
                    if (GUILayout.Button("Remove Photon Integration Component"))
                    {
                        DestroyImmediate(myTarget.gameObject.GetComponent <EnviroPhotonIntegration>());
                    }
                }
                GUILayout.Space(10);
                if (GUILayout.Button("Deactivate Photon Support"))
                {
                    RemoveDefineSymbol("ENVIRO_PHOTON_SUPPORT");
                }
#else
                EditorGUILayout.LabelField("Photon support not activated! Please activate if you have Photon PUN 2 in your project.");
                GUILayout.Space(10);
                if (GUILayout.Button("Activate Photon Support"))
                {
                    AddDefineSymbol("ENVIRO_PHOTON_SUPPORT");
                }
                if (GUILayout.Button("Deactivate Photon Support"))
                {
                    RemoveDefineSymbol("ENVIRO_PHOTON_SUPPORT");
                }
#endif
                GUILayout.EndVertical();
                //////////
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndToggleGroup();
        }
        // END THIRDPARTY



        // END Utilities

        GUILayout.EndVertical();
        EditorGUILayout.EndToggleGroup();


#if ENVIRO_HD
        GUILayout.BeginVertical("", boxStyle);
        myTarget.showUtilities = EditorGUILayout.BeginToggleGroup(" Utilities", myTarget.showUtilities);

        if (myTarget.showUtilities)
        {
            GUILayout.BeginVertical("Export Sky to HDR Cubemap", boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("Cubemap Resolution");
            myTarget.skyBaking.resolution = EditorGUILayout.IntPopup(myTarget.skyBaking.resolution, bakingResNames, bakingResValues);
            GUILayout.Space(5);
            if (GUILayout.Button("Bake to Cubemap"))
            {
                SelectPathForBaking(myTarget.skyBaking.resolution);
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndVertical();
        EditorGUILayout.EndToggleGroup();
#endif
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            TrueSyncConfig settings = (TrueSyncConfig)target;

            Undo.RecordObject(settings, "Edit TrueSyncConfig");

            EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            settings.syncWindow = EditorGUILayout.IntField("Sync Window", settings.syncWindow);
            if (settings.syncWindow < 0)
            {
                settings.syncWindow = 0;
            }

            settings.rollbackWindow = EditorGUILayout.IntField("Rollback Window", settings.rollbackWindow);
            if (settings.rollbackWindow < 0)
            {
                settings.rollbackWindow = 0;
            }

            settings.panicWindow = EditorGUILayout.IntField("Panic Window", settings.panicWindow);
            if (settings.panicWindow < 0)
            {
                settings.panicWindow = 0;
            }

            settings.lockedTimeStep = EditorGUILayout.FloatField("Locked Time Step", settings.lockedTimeStep.AsFloat());
            if (settings.lockedTimeStep < 0)
            {
                settings.lockedTimeStep = 0;
            }


            settings.showStats = EditorGUILayout.Toggle("Show Stats", settings.showStats);

            settings.friction    = EditorGUILayout.Slider("默认摩擦系数", settings.friction.AsFloat(), 0, 1);
            settings.restitution = EditorGUILayout.FloatField("反弹系数", settings.restitution.AsFloat());
            settings.linearDrag  = EditorGUILayout.FloatField("默认线性阻力", settings.linearDrag.AsFloat());
            settings.angularDrag = EditorGUILayout.FloatField("默认旋转阻力", settings.angularDrag.AsFloat());

            EditorGUI.indentLevel--;

            GUILayout.Space(10);

            settings.physics2DEnabled = EditorGUILayout.BeginToggleGroup("2D Physics", settings.physics2DEnabled);

            if (settings.physics2DEnabled)
            {
                settings.physics3DEnabled = false;

                EditorGUI.indentLevel++;

                Vector2 gField2D = EditorGUILayout.Vector2Field("Gravity", settings.gravity2D.ToVector());
                settings.gravity2D.x = gField2D.x;
                settings.gravity2D.y = gField2D.y;

                settings.speculativeContacts2D = EditorGUILayout.Toggle("Speculative Contacts", settings.speculativeContacts2D);

                physics2DCollisionFoldout = EditorGUILayout.Foldout(physics2DCollisionFoldout, "Layer Collision Matrix");
                if (physics2DCollisionFoldout)
                {
                    DrawLayerMatrix(settings.physics2DIgnoreMatrix);
                }

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndToggleGroup();

            settings.physics3DEnabled = EditorGUILayout.BeginToggleGroup("3D Physics", settings.physics3DEnabled);

            if (settings.physics3DEnabled)
            {
                settings.physics2DEnabled = false;

                EditorGUI.indentLevel++;

                Vector3 gField3D = EditorGUILayout.Vector3Field("Gravity", settings.gravity3D.ToVector());
                settings.gravity3D.x = gField3D.x;
                settings.gravity3D.y = gField3D.y;
                settings.gravity3D.z = gField3D.z;

                settings.speculativeContacts3D = EditorGUILayout.Toggle("Speculative Contacts", settings.speculativeContacts3D);

                physics3DCollisionFoldout = EditorGUILayout.Foldout(physics3DCollisionFoldout, "Layer Collision Matrix");
                if (physics3DCollisionFoldout)
                {
                    DrawLayerMatrix(settings.physics3DIgnoreMatrix);
                }

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndToggleGroup();

            serializedObject.ApplyModifiedProperties();

            GUILayout.Space(20);

            if (GUILayout.Button("Highlight Settings"))
            {
                EditorGUIUtility.PingObject(target);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }
示例#21
0
    private void Outline(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("3.Outline", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("OUTBASE_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[14], properties[14].displayName);
                materialEditor.ShaderProperty(properties[15], properties[15].displayName);
                materialEditor.ShaderProperty(properties[16], properties[16].displayName);
                materialEditor.ShaderProperty(properties[17], properties[17].displayName);
                MaterialProperty outline8dir = ShaderGUI.FindProperty("_Outline8Directions", properties);
                if (outline8dir.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTBASE8DIR_ON");
                }
                else
                {
                    targetMat.DisableKeyword("OUTBASE8DIR_ON");
                }

                materialEditor.ShaderProperty(properties[19], properties[19].displayName);
                MaterialProperty outlinePixel = ShaderGUI.FindProperty("_OutlineIsPixel", properties);
                if (outlinePixel.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTBASEPIXELPERF_ON");
                    materialEditor.ShaderProperty(properties[20], properties[20].displayName);
                }
                else
                {
                    targetMat.DisableKeyword("OUTBASEPIXELPERF_ON");
                    materialEditor.ShaderProperty(properties[18], properties[18].displayName);
                }

                materialEditor.ShaderProperty(properties[21], properties[21].displayName);
                MaterialProperty outlineTex = ShaderGUI.FindProperty("_OutlineTexToggle", properties);
                if (outlineTex.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTTEX_ON");
                    materialEditor.ShaderProperty(properties[22], properties[22].displayName);
                    materialEditor.ShaderProperty(properties[23], properties[23].displayName);
                    materialEditor.ShaderProperty(properties[24], properties[24].displayName);
                    materialEditor.ShaderProperty(properties[25], properties[25].displayName);
                    MaterialProperty outlineTexGrey = ShaderGUI.FindProperty("_OutlineTexGrey", properties);
                    if (outlineTexGrey.floatValue == 1)
                    {
                        targetMat.EnableKeyword("OUTGREYTEXTURE_ON");
                    }
                    else
                    {
                        targetMat.DisableKeyword("OUTGREYTEXTURE_ON");
                    }
                }
                else
                {
                    targetMat.DisableKeyword("OUTTEX_ON");
                }

                materialEditor.ShaderProperty(properties[26], properties[26].displayName);
                MaterialProperty outlineDistort = ShaderGUI.FindProperty("_OutlineDistortToggle", properties);
                if (outlineDistort.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTDIST_ON");
                    materialEditor.ShaderProperty(properties[27], properties[27].displayName);
                    materialEditor.ShaderProperty(properties[28], properties[28].displayName);
                    materialEditor.ShaderProperty(properties[29], properties[29].displayName);
                    materialEditor.ShaderProperty(properties[30], properties[30].displayName);
                }
                else
                {
                    targetMat.DisableKeyword("OUTDIST_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("OUTBASE_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
示例#22
0
        protected virtual void OnGUI()
        {
            if (m_windowInformation == null)
            {
                m_windowInformation = new BalloonPluggerWindowInformation();
            }

            EditorGUILayout.BeginHorizontal();

            bool v_refreshClicked = GUILayout.Button("Refresh Informations");

            EditorGUILayout.EndHorizontal();

            if (v_refreshClicked)
            {
                Refresh();
            }

            if (m_windowInformation.Ballons != null)
            {
                EditorGUILayout.BeginHorizontal();

                GUILayout.Label("Ballon");
                m_windowInformation.SelectedBallonIndex = EditorGUILayout.Popup(m_windowInformation.SelectedBallonIndex, m_windowInformation.Ballons.GetStringList().ToArray());

                EditorGUILayout.EndHorizontal();
            }

            if (m_windowInformation.Ropes != null)
            {
                EditorGUILayout.BeginHorizontal();

                GUILayout.Label("Ropes");
                m_windowInformation.SelectedRopeIndex = EditorGUILayout.Popup(m_windowInformation.SelectedRopeIndex, m_windowInformation.Ropes.GetStringList().ToArray());

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();

            GUILayout.Label("Plug In Selected Object In Scene");

            m_windowInformation.PlugInSelectedObject = EditorGUILayout.BeginToggleGroup("", m_windowInformation.PlugInSelectedObject);
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.EndHorizontal();

            if (!m_windowInformation.PlugInSelectedObject)
            {
                EditorGUILayout.BeginHorizontal();

                m_windowInformation.ObjectInSceneToPlug = (GameObject)EditorGUILayout.ObjectField("Object To Plug", m_windowInformation.ObjectInSceneToPlug, typeof(GameObject), true);

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                Transform v_transform = Selection.activeTransform;
                if (v_transform != null)
                {
                    m_windowInformation.ObjectInSceneToPlug = v_transform.gameObject;
                }
            }

            BalloonProperty v_ballonPrefabComponent = m_windowInformation.Ballons != null && m_windowInformation.SelectedBallonIndex >= 0 && m_windowInformation.Ballons.Count > m_windowInformation.SelectedBallonIndex ? m_windowInformation.Ballons[m_windowInformation.SelectedBallonIndex] : null;
            TackRope        v_ropePrefabComponent   = m_windowInformation.Ropes != null && m_windowInformation.SelectedRopeIndex >= 0 && m_windowInformation.Ropes.Count > m_windowInformation.SelectedRopeIndex ? m_windowInformation.Ropes[m_windowInformation.SelectedRopeIndex] : null;

            if (m_windowInformation.ObjectInSceneToPlug != null && v_ballonPrefabComponent != null && v_ropePrefabComponent != null)
            {
                EditorGUILayout.BeginHorizontal();

                bool v_buttonClicked = GUILayout.Button("Plug Ballon");

                EditorGUILayout.EndHorizontal();

                if (v_buttonClicked)
                {
                    PlugBallon();
                }
            }
        }
示例#23
0
    public void OnGUI()
    {
        genClass.OnGUI();

        useTexturing = EditorGUILayout.BeginToggleGroup("Setup textures", useTexturing);

        if (useTexturing)
        {
            if (GUILayout.Button("Clear all textures"))
            {
                List <TTexture> textures = new List <TTexture>();
                TerrainTexturing.GenerateTexture(textures);
            }

            foreach (var texture in texClass)
            {
                texture.OnGUI();
            }

            if (texClass.Count > 0)
            {
                if (GUILayout.Button("Delete last"))
                {
                    texClass.RemoveAt(texClass.Count - 1);
                }
            }

            if (GUILayout.Button("Add texture"))
            {
                texClass.Add(new wbTexturing());
            }

            if (texClass.Count > 0 && texClass[texClass.Count - 1].texture != null)
            {
                if (GUILayout.Button("Assign new textures"))
                {
                    List <TTexture> textures = new List <TTexture>();
                    for (int i = 0; i < texClass.Count; i++)
                    {
                        TTexture TTex = new TTexture();
                        TTex.texture = texClass[i].texture;
                        //TTex.color = texClass[i].color;
                        TTex.useBump = texClass[i].useBump;
                        if (texClass[i].useBump)
                        {
                            TTex.bumpmap = texClass[i].bumpmap;
                        }
                        else
                        {
                            TTex.bumpmap = texClass[i].emptyBump;
                        }
                        TTex.tilesize    = texClass[i].tilesize;
                        TTex.index       = texClass[i].index;
                        TTex.heightCurve = texClass[i].heightCurve;
                        TTex.angleCurve  = texClass[i].angleCurve;
                        textures.Add(TTex);
                    }
                    TerrainTexturing.GenerateTexture(textures);
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        useFoliage = EditorGUILayout.BeginToggleGroup("Setup foliage", useFoliage);

        if (useFoliage)
        {
            waterCoast   = EditorGUILayout.FloatField("Tree distance from coast", waterCoast);
            maxSteepness = EditorGUILayout.FloatField("Max hill angle for trees", maxSteepness);

            if (GUILayout.Button("Generate trees"))
            {
                TerrainFoliage.maxSteepness = maxSteepness;
                if (GameObject.Find("Water"))
                {
                    TerrainFoliage.waterLevel = GameObject.Find("Water").transform.position.y + waterCoast;
                }
                else
                {
                    TerrainFoliage.waterLevel = 0.0f;
                }
                TerrainFoliage.GenerateFoliage();
            }

            if (GUILayout.Button("Remove trees"))
            {
                TerrainFoliage.ClearTrees();
            }

            grassDensity = EditorGUILayout.IntField("Grass density", grassDensity);

            if (GUILayout.Button("Generate grass"))
            {
                TerrainFoliage.GenerateGrass();
            }

            if (GUILayout.Button("Remove grass"))
            {
                TerrainFoliage.ClearGrass();
            }
        }

        EditorGUILayout.EndToggleGroup();
    }
示例#24
0
        /// <summary>
        /// Draws a common inspector
        /// </summary>
        /// <param name="targetAnimator"></param>
        protected void DrawInspector(BaseAnimator targetAnimator)
        {
            if (!init)
            {
                Init(targetAnimator);
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Basic Settings");

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Ignore time scale", GUILayout.ExpandWidth(false));
                GUILayout.FlexibleSpace();
                EditorGUILayout.PropertyField(ignoreTimeScale, emptyContent, GUILayout.ExpandWidth(false));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Start at random frame", GUILayout.ExpandWidth(false));
                GUILayout.FlexibleSpace();
                EditorGUILayout.PropertyField(startAtRandomFrame, emptyContent, GUILayout.ExpandWidth(false));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Play on awake", GUILayout.ExpandWidth(false));
                GUILayout.FlexibleSpace();
                EditorGUILayout.PropertyField(playOnAwake, emptyContent, GUILayout.ExpandWidth(false));
                EditorGUILayout.EndHorizontal();

                if (playOnAwake.boolValue)
                {
                    EditorGUI.indentLevel++;

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("One shot", GUILayout.ExpandWidth(false));
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.PropertyField(oneShot, emptyContent, GUILayout.ExpandWidth(false));
                    EditorGUILayout.EndHorizontal();

                    if (!oneShot.boolValue)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(loopType);
                        delayBetweenLoops.boolValue = EditorGUILayout.BeginToggleGroup("Delay", delayBetweenLoops.boolValue);
                        {
                            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
                            EditorGUIUtility.labelWidth = 65;
                            EditorGUILayout.PropertyField(minDelayBetweenLoops, new GUIContent("Min"));
                            EditorGUILayout.PropertyField(maxDelayBetweenLoops, new GUIContent("Max"));
                            EditorGUIUtility.labelWidth = 0;
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorGUILayout.EndToggleGroup();

                        if (minDelayBetweenLoops.floatValue < 0)
                        {
                            minDelayBetweenLoops.floatValue = 0;
                        }

                        if (maxDelayBetweenLoops.floatValue < minDelayBetweenLoops.floatValue)
                        {
                            maxDelayBetweenLoops.floatValue = minDelayBetweenLoops.floatValue;
                        }

                        EditorGUI.indentLevel--;
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Disable render on finish", GUILayout.ExpandWidth(false));
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.PropertyField(disableRendererOnFinish, emptyContent, GUILayout.ExpandWidth(false));
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Backwards", GUILayout.ExpandWidth(false));
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.PropertyField(backwards, emptyContent, GUILayout.ExpandWidth(false));
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Random animation", GUILayout.ExpandWidth(false));
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.PropertyField(randomAnimation, emptyContent, GUILayout.ExpandWidth(false));
                    EditorGUILayout.EndHorizontal();

                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            showAnimationList = EditorGUI.Foldout(GUILayoutUtility.GetRect(40f, 40f, 16f, 16f), showAnimationList, "Animation List", true);

            DragAndDropBox(targetAnimator);

            if (showAnimationList)
            {
                DrawAnimationList(targetAnimator);
            }
            else
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.EndVertical();
            }

            if (draggedAnimations != null && draggedAnimations.Count > 0)
            {
                showAnimationList = true;
                for (int i = 0; i < draggedAnimations.Count; i++)
                {
                    targetAnimator.animations.Add(draggedAnimations[i]);
                    if (targetAnimator.animations.Count == 1 && targetAnimator.animations[0] != null)
                    {
                        targetAnimator.StartAnimation = targetAnimator.animations[0].Name;
                    }
                }

                draggedAnimations.Clear();
            }

            if (GUI.changed)
            {
                EditorPrefs.SetBool(SHOW_ANIMATION_LIST_KEY, showAnimationList);
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(targetAnimator);
            }
        }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        ShadowProjector shadowProj = (ShadowProjector)target;

        shadowProj.GlobalProjectionDir = EditorGUILayout.Vector3Field("Global light direction", shadowProj.GlobalProjectionDir, null);

        shadowProj.GlobalShadowResolution = EditorGUILayout.Popup("Global shadow resolution", shadowProj.GlobalShadowResolution, _ShadowResOptions);

        shadowProj.GlobalShadowCullingMode = (GlobalProjectorManager.ProjectionCulling)EditorGUILayout.Popup("Global culling mode", (int)shadowProj.GlobalShadowCullingMode, _CullingOptions);



        shadowProj.EnableCutOff         = EditorGUILayout.BeginToggleGroup("Cutoff shadow by distance?", shadowProj.EnableCutOff);
        shadowProj.GlobalCutOffDistance = EditorGUILayout.Slider("Global cutoff distance", shadowProj.GlobalCutOffDistance, 1.0f, 10000.0f);
        EditorGUILayout.EndToggleGroup();


        shadowProj.GlobalFlipX = EditorGUILayout.Toggle("Global flip shadows X:", shadowProj.GlobalFlipX);
        shadowProj.GlobalFlipY = EditorGUILayout.Toggle("Global flip shadows Y:", shadowProj.GlobalFlipY);

        shadowProj.ShadowSize = EditorGUILayout.FloatField("Shadow size", shadowProj.ShadowSize);

        shadowProj.ShadowColor = EditorGUILayout.ColorField("Shadow color", shadowProj.ShadowColor);

        shadowProj.ShadowOpacity = EditorGUILayout.Slider("Shadow opacity", shadowProj.ShadowOpacity, 0.0f, 1.0f);

        shadowProj.IsLight = EditorGUILayout.Toggle("Is light?", shadowProj.IsLight);

        shadowProj._Material = (Material)EditorGUILayout.ObjectField("Shadow material", (Object)shadowProj._Material, typeof(Material), false, null);

        EditorGUILayout.LabelField("Shadow UV Rect");

        UVRect = shadowProj.UVRect;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("X:", GUILayout.MaxWidth(15));
        UVRect.x = EditorGUILayout.FloatField(UVRect.x, GUILayout.ExpandWidth(true));
        EditorGUILayout.LabelField("Y:", GUILayout.MaxWidth(15));
        UVRect.y = EditorGUILayout.FloatField(UVRect.y, GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("W:", GUILayout.MaxWidth(15));
        UVRect.width = EditorGUILayout.FloatField(UVRect.width, GUILayout.ExpandWidth(true));
        EditorGUILayout.LabelField("H:", GUILayout.MaxWidth(15));
        UVRect.height = EditorGUILayout.FloatField(UVRect.height, GUILayout.ExpandWidth(true));

        EditorGUILayout.EndHorizontal();

        shadowProj.ShadowLocalOffset = EditorGUILayout.Vector3Field("Shadow local offset", shadowProj.ShadowLocalOffset, null);


        shadowProj.RotationAngleOffset = Quaternion.Euler(EditorGUILayout.Vector3Field("Rotation angle offsets", shadowProj.RotationAngleOffset.eulerAngles));

        EditorGUILayout.LabelField("Freeze rotation:");
        shadowProj.FreezeXRot = EditorGUILayout.Toggle("  X", shadowProj.FreezeXRot);
        shadowProj.FreezeYRot = EditorGUILayout.Toggle("  Y", shadowProj.FreezeYRot);
        shadowProj.FreezeZRot = EditorGUILayout.Toggle("  Z", shadowProj.FreezeZRot);

        if (GUILayout.Button("Open UV Editor"))
        {
            ShadowTextureUVEditor.Open(shadowProj);
        }

        shadowProj.AutoSizeOpacity          = EditorGUILayout.BeginToggleGroup("Auto opacity/size:", shadowProj.AutoSizeOpacity);
        shadowProj.AutoSORaycastLayer       = EditorGUILayout.LayerField("Raycast layer", shadowProj.AutoSORaycastLayer);
        shadowProj.AutoSORayOriginOffset    = EditorGUILayout.FloatField("Ray origin offset", shadowProj.AutoSORayOriginOffset);
        shadowProj.AutoSOCutOffDistance     = EditorGUILayout.FloatField("Cutoff distance", shadowProj.AutoSOCutOffDistance);
        shadowProj.AutoSOMaxScaleMultiplier = EditorGUILayout.FloatField("Max scale multiplier", shadowProj.AutoSOMaxScaleMultiplier);

        EditorGUILayout.EndToggleGroup();

        shadowProj.UVRect = UVRect;

        if (!GlobalProjectorLayerExists())
        {
            CheckGlobalProjectorLayer();
        }

        serializedObject.ApplyModifiedProperties();

        ApplyGlobalSettings();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    void drawFields()
    {
        //GUILayout.Label(bannerImage, GUILayout.ExpandWidth(true));
        //EditorGUI.DrawTextureAlpha(EditorGUILayout.RectField(new Rect(0, 0, 383, 91)), bannerImage, ScaleMode.StretchToFill);

        if (material == null || !shaderName.Contains("StylizedWater"))
        {
            EditorGUILayout.HelpBox("Please assign a \"StylizedWater\" shader to the current material", MessageType.Error);
        }
        else
        {
            EditorGUILayout.LabelField("Current shader: ", shaderName, EditorStyles.boldLabel);
        }

        #region Substance
        ProceduralMaterial mSubstance = substance;
        substance = (ProceduralMaterial)EditorGUILayout.ObjectField("Substance", substance, typeof(ProceduralMaterial), true);

        if (mSubstance != substance)
        {
            //Debug.Log("Substance has changed: " + mSubstance.name + " > " + substance.name);
            hasSubstanceParams = false;
        }

        if (!substance)
        {
            EditorGUILayout.HelpBox("Please assign a Substance material instance", MessageType.Error);
        }

        //If conditions aren't met, don't display fields
        if (!substance || !shaderName.Contains("StylizedWater"))
        {
            return;
        }


        EditorGUILayout.BeginHorizontal();

        seed = EditorGUILayout.FloatField("Seed", seed);
        if (GUILayout.Button("Randomize", EditorStyles.miniButton))
        {
            seed = Random.Range(1, 9999);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        #endregion

        #region Colors
        if (GUILayout.Button((showColors) ? "[-] Colors" : "[+] Colors", groupFoldout))
        {
            showColors = !showColors;
        }
        if (showColors)
        {
            waterColor = EditorGUILayout.ColorField("Water color", waterColor);
            if (!isMobileBasic)
            {
                fresnelColor = EditorGUILayout.ColorField("Fresnel color", fresnelColor);
            }
            rimColor = EditorGUILayout.ColorField("Rim color", rimColor);
        }

        EditorGUILayout.Space();
        #endregion

        #region Surface
        if (GUILayout.Button((showSurface) ? "[-] Surface" : "[+] Surface", groupFoldout))
        {
            showSurface = !showSurface;
        }
        if (showSurface)
        {
            if (!useCustomNormals)
            {
                normalStrength = EditorGUILayout.Slider("Normal strength", normalStrength, 0f, 32f);
            }
            worldSpaceTiling = EditorGUILayout.Toggle("World-space tiling", worldSpaceTiling);
            tiling           = EditorGUILayout.Slider("Tiling", tiling, 0f, 1f);

            if (!isMobileBasic)
            {
                transparency = EditorGUILayout.Slider("Transparency", transparency, 0f, 1f);
                fresnel      = EditorGUILayout.Slider("Fresnel", fresnel, 0f, 10f);
            }
            glossiness = EditorGUILayout.Slider("Glossiness", glossiness, 0f, 1f);


            if (!isMobileAdvanced && !isMobileBasic)
            {
                refractionAmount  = EditorGUILayout.Slider("Refraction", refractionAmount, 0f, 0.2f);
                reflectionCubemap = (Texture)EditorGUILayout.ObjectField("Reflection cubemap", reflectionCubemap, typeof(Cubemap), false);
            }
        }

        EditorGUILayout.Space();
        #endregion

        #region Intersection
        if (GUILayout.Button((showIntersection) ? "[-] Intersection" : "[+] Intersection", groupFoldout))
        {
            showIntersection = !showIntersection;
        }
        if (showIntersection)
        {
            useCustomIntersection = EditorGUILayout.BeginToggleGroup("Use custom texture", useCustomIntersection);
            if (useCustomIntersection)
            {
                customIntersection = (Texture)EditorGUILayout.ObjectField("Grayscale texture", customIntersection, typeof(Texture2D), false);
                if (customIntersection == null)
                {
                    EditorGUILayout.HelpBox("Texture cannot be empty", MessageType.Warning);
                }
            }

            EditorGUILayout.EndToggleGroup();


            if (!useCustomIntersection)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Style");
                intersectionStyle = EditorGUILayout.Popup(intersectionStyle, intersectionStyleList, EditorStyles.toolbarDropDown);
                EditorGUILayout.EndHorizontal();
            }


            rimSize    = EditorGUILayout.Slider("Size", rimSize, 0f, 10f);
            rimFalloff = EditorGUILayout.Slider("Falloff", rimFalloff, 0f, 5f);
            if (!isMobileBasic)
            {
                rimDistance = EditorGUILayout.Slider("Distance", rimDistance, 0f, 1f);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Tiling");
            if (GUILayout.Button("<<", EditorStyles.miniButtonLeft))
            {
                rimTiling -= .5f;
            }
            if (GUILayout.Button("<", EditorStyles.miniButton))
            {
                rimTiling -= .1f;
            }
            rimTiling = EditorGUILayout.FloatField(rimTiling, GUILayout.MaxWidth(25));
            if (GUILayout.Button(">", EditorStyles.miniButton))
            {
                rimTiling += .1f;
            }
            if (GUILayout.Button(">>", EditorStyles.miniButtonRight))
            {
                rimTiling += .5f;
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
        #endregion

        #region Surface highlights
        if (!isMobileBasic)
        {
            if (GUILayout.Button((showHighlights) ? "[-] Surface highlights" : "[+] Surface highlights", groupFoldout))
            {
                showHighlights = !showHighlights;
            }
            if (showHighlights)
            {
                surfaceHighlight     = EditorGUILayout.Slider("Opacity", surfaceHighlight, 0f, 1f);
                surfaceHighlightSize = EditorGUILayout.Slider("Size", surfaceHighlightSize, 0f, 1f);

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Tiling");
                if (GUILayout.Button("<<", EditorStyles.miniButtonLeft))
                {
                    surfaceHighlightTiling -= .5f;
                }
                if (GUILayout.Button("<", EditorStyles.miniButton))
                {
                    surfaceHighlightTiling -= .1f;
                }
                surfaceHighlightTiling = EditorGUILayout.FloatField(surfaceHighlightTiling, GUILayout.MaxWidth(25));
                if (GUILayout.Button(">", EditorStyles.miniButton))
                {
                    surfaceHighlightTiling += .1f;
                }
                if (GUILayout.Button(">>", EditorStyles.miniButtonRight))
                {
                    surfaceHighlightTiling += .5f;
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
        }//not mobile basic
        #endregion

        #region Depth
        if (!isMobileBasic)
        {
            if (GUILayout.Button((showDepth) ? "[-] Depth" : "[+] Depth", groupFoldout))
            {
                showDepth = !showDepth;
            }
            if (showDepth)
            {
                depth         = EditorGUILayout.Slider("Depth", depth, 0f, 30f);
                depthDarkness = EditorGUILayout.Slider("Darkness", depthDarkness, 0f, 1f);
            }

            EditorGUILayout.Space();
        }
        #endregion

        #region Waves
        if (GUILayout.Button((showWaves) ? "[-] Waves" : "[+] Waves", groupFoldout))
        {
            showWaves = !showWaves;
        }
        if (showWaves)
        {
            useCustomNormals = EditorGUILayout.BeginToggleGroup("Use custom normal map", useCustomNormals);
            if (useCustomNormals)
            {
                customNormal = (Texture)EditorGUILayout.ObjectField("Normal map", customNormal, typeof(Texture2D), false);
                if (customNormal == null)
                {
                    EditorGUILayout.HelpBox("Texture cannot be empty", MessageType.Warning);
                }
            }


            EditorGUILayout.EndToggleGroup();

            if (!useCustomNormals)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Style");
                waveStyle = EditorGUILayout.Popup(waveStyle, waveStyleList, EditorStyles.toolbarDropDown);
                EditorGUILayout.EndHorizontal();
            }

            waveSpeed = EditorGUILayout.Slider("Speed", waveSpeed, 0f, 10f);
            if (!isMobileAdvanced && !isMobileBasic)
            {
                waveStrength = EditorGUILayout.Slider("Strength", waveStrength, 0f, 1f);
            }
        }

        EditorGUILayout.Space();
        #endregion

        if (shaderName.Contains("Tesselation"))
        {
            tesselation = EditorGUILayout.Slider("Tesselation", tesselation, 0.1f, 10f);
        }
    }
示例#27
0
        protected void DrawMeshConstructTool()
        {
            string buttonStr = string.Empty;

            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                animBool_vertex.target = EditorGUILayout.BeginToggleGroup("顶点相关", animBool_vertex.target);
                if (EditorGUILayout.BeginFadeGroup(animBool_vertex.faded))
                {
                    buttonStr = vertexEditorMode ? "生成Camera顶点<Ctrl +Q>" : "生成Camera顶点";
                    if (GUILayout.Button(new GUIContent(buttonStr, "<顶点>编辑模式下,激活快捷键<Ctrl + Q>")))
                    {
                        GeneralVertex <TVertex>();
                    }

                    if (GUILayout.Button("选中所有顶点"))
                    {
                        var tCameraVertexs = GameObject.FindObjectsOfType <TVertex>();

                        var gobjs = new List <Object>();
                        for (int i = 0; i < tCameraVertexs.Length; i++)
                        {
                            gobjs.Add(tCameraVertexs[i].gameObject);
                        }

                        Selection.objects = gobjs.ToArray();
                    }
                }

                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                animBool_trangle.target = EditorGUILayout.BeginToggleGroup("三角形相关", animBool_trangle.target);

                if (EditorGUILayout.BeginFadeGroup(animBool_trangle.faded))
                {
                    if (GUILayout.Button("将所有三角形Gobj移动至重心"))
                    {
                        MoveAllTrangleGobjToCentroid();
                    }

                    if (GUILayout.Button("将三角形加入网格"))
                    {
                        if (Selection.gameObjects.Length <= 0)
                        {
                            EditorUtility.DisplayDialog("提醒", "请选择至少1个三角形", "知道了");
                            return;
                        }
                        var tCameraTrangles = new List <TTrangle>();
                        for (int i = 0; i < Selection.gameObjects.Length; i++)
                        {
                            var gobj   = Selection.gameObjects[i];
                            var vertex = gobj.GetComponent <TTrangle>();
                            if (vertex == null)
                            {
                                continue;
                            }

                            tCameraTrangles.Add(vertex);
                        }

                        Mesh tCamearMesh = null;

                        if (!util.TryGetCameraMesh(out tCamearMesh))
                        {
                            return;
                        }

                        UnityEditor.Undo.RecordObject(tCamearMesh, "Add Trangle");

                        for (int i = 0; i < tCameraTrangles.Count; i++)
                        {
                            var trangle = tCameraTrangles[i];
                            if (!tCamearMesh.AddTrangle(trangle))
                            {
                                continue;
                            }
                        }
                        EditorUtility.SetDirty(tCamearMesh);
                    }

                    if (GUILayout.Button("选中所有三角形"))
                    {
                        var objs = GameObject.FindObjectsOfType <Trangle>();

                        var gobjs = new List <Object>();
                        for (int i = 0; i < objs.Length; i++)
                        {
                            gobjs.Add(objs[i].gameObject);
                        }

                        Selection.objects = gobjs.ToArray();
                    }
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                animBool_editor.target = EditorGUILayout.BeginToggleGroup("编辑模式", animBool_editor.target);

                if (EditorGUILayout.BeginFadeGroup(animBool_editor.faded))
                {
                    GUI.color = vertexEditorMode ? new Color(0f, 0.95f, 0.95f, 1f) : Color.white;
                    buttonStr = vertexEditorMode ? "关闭<顶点>编辑模式" : "开启<顶点>编辑模式";
                    if (GUILayout.Button(new GUIContent(buttonStr, "<顶点>编辑模式下,框选只会选择到<顶点>,而且激活生成顶点快捷键<Ctrl + Q> 和顶 点合并快捷键<Ctrl + X>")))
                    {
                        vertexEditorMode = !vertexEditorMode;
                    }
                    GUI.color = Color.white;

                    GUI.color = trangleEditorMode ? new Color(0f, 0.95f, 0.95f, 1f) : Color.white;
                    buttonStr = trangleEditorMode ? "关闭<三角形>编辑模式" : "开启<三角形>编辑模式";
                    if (GUILayout.Button(new GUIContent(buttonStr, "开启后只会框选到<三角形>")))
                    {
                        trangleEditorMode = !trangleEditorMode;
                    }
                    GUI.color = Color.white;
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }

            buttonStr = vertexEditorMode ? "合并顶点成三角形<Ctrl +X>" : "合并顶点成三角形";
            if (GUILayout.Button(new GUIContent(buttonStr, "<顶点>编辑模式下,激活快捷键<Ctrl +X>")))
            {
                CombineVerticesToTrangle();
            }

            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
        }
示例#28
0
        void OnGUI()
        {
            // 此处为实际窗口代码
            scrollPosBig = EditorGUILayout.BeginScrollView(scrollPosBig);

            // ToolBar工具栏,横向选择
            string[] toolBarStrs = { "Selection1", "Selection2", "Selection3" };
            toolBarSelect = GUILayout.Toolbar(toolBarSelect, toolBarStrs, GUILayout.Height(25));

            // 非下拉选择网格,可以给横向或者纵向
            string[] gridStrs = { "Message1", "Message2", "Message3", "Message4" };
            gridSelection = GUILayout.SelectionGrid(gridSelection, gridStrs, 2);

            // 下拉选项菜单
            string[] options  = { "Popup选项一", "Popup选项二", "Popup选项三" };
            var      oldValue = optionIndex;

            optionIndex = EditorGUILayout.Popup(optionIndex, options);
            if (optionIndex != oldValue)
            {
                Debug.Log("选项发生变化:" + optionIndex);
            }

            // 整数下拉选项
            string[] names      = { "number1", "number2", "number4" };
            int[]    sizes      = { 1, 2, 4 };
            int      selectSize = 4;

            EditorGUILayout.IntPopup("整数下拉: ", selectSize, names, sizes);

            // 枚举选项菜单
            optionEnum = (EnumOption)EditorGUILayout.EnumPopup("枚举选项:", optionEnum);
            EditorGUILayout.PrefixLabel("PreFixLabel");
            // 带箭头的折叠项
            foldOut = EditorGUILayout.Foldout(foldOut, "Foldout");
            if (foldOut)
            {
                // 标签字段
                GUILayout.Label("  隐藏项", EditorStyles.boldLabel);
            }



            // 标签字段
            GUIStyle fontStyle = new GUIStyle();

            fontStyle.fontSize = 20;
            EditorGUILayout.LabelField("Base Settings", fontStyle, GUILayout.MinHeight(25));

            // 曲线属性
            curve = EditorGUILayout.CurveField("曲线属性", curve);

            // 整数字段
            EditorGUILayout.IntField("整数字段", 1);

            // 浮点数字段
            EditorGUILayout.FloatField("浮点数字段", 1.25f);

            // 二维向量字段
            EditorGUILayout.Vector2Field("二维向量字段", Vector2.left);

            // 颜色字段
            EditorGUILayout.ColorField("颜色字段", Color.yellow);

            // GameObject字段
            gameObjectField =
                EditorGUILayout.ObjectField("gameObjectField", gameObjectField, typeof(GameObject),
                                            false) as GameObject;
            if (gameObjectField != null)
            {
                string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(gameObjectField);
                EditorGUILayout.LabelField("prefab: " + prefabPath);
            }

            // tag拾取文本,给gameObject设置tag
            EditorGUILayout.TagField("GameObjectTag:", "Untagged");

            // layer拾取文本,给gameObject设置layer
            EditorGUILayout.LayerField("GameObjectLayer:", 0);

            // materialField字段
            materialField =
                EditorGUILayout.ObjectField("materialField", materialField, typeof(Material), false) as Material;

            // 文本输入框
            myString = EditorGUILayout.TextField("账号:", myString);

            // 密码输入框
            password = EditorGUILayout.PasswordField("Password:", password);

            // 文本输入区域
            EditorGUILayout.PrefixLabel("文本输入区域");
            myString = EditorGUILayout.TextArea(myString);

            // 禁用区域:当groupEnabled为true时才能修改group范围内的值
            groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
            // 单选框(如果没有myBool = 则不能修改)
            myBool = EditorGUILayout.Toggle("Toggle", myBool);
            // 进度条
            myFloat = EditorGUILayout.Slider("Slider", myFloat, 0, 1);
            //指定生命值的宽高
            Rect progressRect = GUILayoutUtility.GetRect(50, 50);

            // 用滑块绘制生命条
            GUI.color = Color.cyan;
            EditorGUI.ProgressBar(progressRect, myFloat, "生命值");
            GUI.color = Color.white;
            EditorGUILayout.EndToggleGroup();

            // 帮助盒子
            EditorGUILayout.HelpBox("伤害太低了吧!!", MessageType.Error);
            EditorGUILayout.HelpBox("伤害有点高啊!!", MessageType.Warning);
            EditorGUILayout.HelpBox("伤害适中!!", MessageType.Info);

            // 焦点和光标
            if (EditorWindow.focusedWindow != null)
            {
                EditorGUILayout.LabelField("键盘焦点window:" + EditorWindow.focusedWindow.ToString());
                EditorGUILayout.LabelField("光标下的window:" + EditorWindow.focusedWindow.ToString());
            }

            // 添加滚动区域(此处需要加scrollPos = ,才能改变值)
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.MinHeight(100), GUILayout.MaxHeight(220));
            // 开始窗口里的子窗口
            this.BeginWindows();
            var windowRect = new Rect(0, 0, 100, 100);

            GUILayout.Window(1, windowRect, (int winID) =>
            {
                GUILayout.Button(winID.ToString());
                GUILayout.Button(scrollPos.ToString());
                GUI.DragWindow();
            }, "子窗口1");
            windowRect.y += 100;
            GUILayout.Window(2, windowRect, (int winID) =>
            {
                GUILayout.Button(winID.ToString());
                GUILayout.Button(scrollPos.ToString());
                GUI.DragWindow();
            }, "子窗口2");
            // 子窗口结束
            this.EndWindows();
            EditorGUILayout.LabelField("", GUILayout.Width(100), GUILayout.Height(200));
            // 滚动区域结束
            EditorGUILayout.EndScrollView();

            //空一行
            EditorGUILayout.Space();

            //以水平方向绘制
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.MaxWidth(50));
            EditorGUILayout.TextField("小丽");
            EditorGUILayout.LabelField("Size", GUILayout.MaxWidth(50));
            EditorGUILayout.TextField("36D");
            EditorGUILayout.EndHorizontal();

            // 发送事件
            if (GUILayout.Button("发送事件", GUILayout.ExpandHeight(true)))
            {
                var win = EditorWindow.GetWindow <MyWindow>();
                win.SendEvent(EditorGUIUtility.CommandEvent("【按钮事件】"));
            }

            // 接收事件
            Event e = Event.current;

            if (e.commandName != "")
            {
                Debug.Log("收到:" + e.commandName);
            }

            // 保存路径文件夹选取面板
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("保存文件夹路径", GUILayout.ExpandWidth(false)))
            {
                filePath = EditorUtility.SaveFolderPanel("Path to Save Images", filePath, Application.dataPath);
            }

            EditorGUILayout.LabelField("当前路径:" + filePath);
            EditorGUILayout.EndHorizontal();

            // 保存路径文件选择面板
            if (GUILayout.Button("保存文件路径"))
            {
                string path = EditorUtility.SaveFilePanel(
                    "Save texture as PNG",
                    "",
                    "123.png",
                    "png");
                Debug.Log("图片路径:" + path);
            }

            // 文件拖拽控制区域demo
            EditorGUILayout.LabelField("文件拖拽框: ");
            var rect = EditorGUILayout.GetControlRect(GUILayout.Height(30));

            rectString = EditorGUI.TextField(rect, rectString);
            EditorGUILayout.ObjectField("拖拽的GameObject", dragObject, typeof(GameObject),
                                        false);
            if ((Event.current.type == UnityEngine.EventType.DragExited ||
                 Event.current.type == UnityEngine.EventType.DragUpdated) &&
                rect.Contains(Event.current.mousePosition))             //如果鼠标正在拖拽中或拖拽结束时,并且鼠标所在位置在文本输入框内
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Generic; //改变鼠标的外表
                if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
                {
                    rectString = DragAndDrop.paths[0]; // 拖拽的文件
                }

                if (DragAndDrop.objectReferences != null && DragAndDrop.objectReferences.Length > 0)
                {
                    dragObject = DragAndDrop.objectReferences[0] as GameObject; // 拖拽的游戏对象
                }
            }

            // 打开一个通知栏
            if (GUILayout.Button("打开通知栏"))
            {
                this.ShowNotification(new GUIContent("This is a Notification"));
            }

            // 关闭通知栏
            if (GUILayout.Button("关闭"))
            {
                this.RemoveNotification();
            }

            // 打开一个进度条弹窗
            if (GUILayout.Button("打开进度条弹窗", GUILayout.MinHeight(30)))
            {
                EditorUtility.DisplayProgressBar("正在解压", "解压期间不消耗流量...", 0.56f);
            }

            // 清空进度条
            if (GUILayout.Button("清空进度条弹窗", GUILayout.MinHeight(30)))
            {
                EditorUtility.ClearProgressBar();
            }

            //编辑器下创建gameObject
            if (GUILayout.Button("创建游戏对象"))
            {
                GameObject created = EditorUtility.CreateGameObjectWithHideFlags("新建游戏对象",
                                                                                 HideFlags.None);
            }

            // 显示普通对话框
            if (GUILayout.Button("显示普通对话框"))
            {
                if (EditorUtility.DisplayDialog("标题,标题", "内容,内容", "确认", "取消"))
                {
                    Debug.Log("点击了确认!");
                }
            }

            // 显示复杂对话框
            if (GUILayout.Button("显示复杂对话框"))
            {
                var option = EditorUtility.DisplayDialogComplex(
                    "标题",
                    "内容,内容...",
                    "确定",
                    "取消",
                    "其他");
                switch (option)
                {
                case 0:
                    Debug.Log("点击了【确定】");
                    break;

                case 1:
                    Debug.Log("点击了【取消】");
                    break;

                case 2:
                    Debug.Log("点击了【其他】");
                    break;

                default:
                    Debug.Log("default switch");
                    break;
                }
            }

            // DisplayPopupMenu显示弹出菜单栏(比如Assets窗口或者Inspector窗口)
            if (GUILayout.Button("显示弹出菜单栏"))
            {
                Rect contextRect = new Rect(10, 10, 100, 100);
                EditorUtility.DisplayPopupMenu(contextRect, "Assets/", null);
            }

            // 使项目窗口到前面并焦点它,这个通常在一个菜单项创建并选择一个资源之后被调用。
            if (GUILayout.Button("Focus Unity工程"))
            {
                EditorUtility.FocusProjectWindow();
            }

            // 右键菜单
            var eventItem = Event.current;

            if (eventItem.type == UnityEngine.EventType.ContextClick)
            {
                var mousePos = eventItem.mousePosition;
                Debug.Log("弹出右键菜单:" + mousePos);
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("选项1"), false, (userData) => { Debug.Log(userData); }, "点击item1");
                menu.AddItem(new GUIContent("选项2/1"), false, (userData) => { Debug.Log(userData); }, "点击item2.1");
                menu.AddItem(new GUIContent("选项2/2"), false, (userData) => { Debug.Log(userData); }, "点击item2.2");
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("选项3"), false, (userData) => { Debug.Log(userData); }, "点击item3");
                menu.ShowAsContext();
                eventItem.Use();
            }


            EditorGUILayout.EndScrollView();
        }
示例#29
0
    public override void OnInspectorGUI()
    {
        if (AdvGame.GetReferences() == null)
        {
            Debug.LogError("A References file is required - please use the Adventure Creator window to create one.");
            EditorGUILayout.LabelField("No References file found!");
        }
        else
        {
            if (!inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }

            _target.hotspotName  = EditorGUILayout.TextField("Label (if not object name):", _target.hotspotName);
            _target.highlight    = (Highlight)EditorGUILayout.ObjectField("Object to highlight:", _target.highlight, typeof(Highlight), true);
            _target.walkToMarker = (Marker)EditorGUILayout.ObjectField("Walk-to marker:", _target.walkToMarker, typeof(Marker), true);

            // Use
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Use interaction", EditorStyles.boldLabel);

            if (!_target.provideUseInteraction)
            {
                if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RegisterSceneUndo("Create use interaction");
                    _target.provideUseInteraction = true;
                }
            }
            else
            {
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RegisterSceneUndo("Delete use interaction");
                    _target.provideUseInteraction = false;
                }
            }

            EditorGUILayout.EndHorizontal();
            if (_target.provideUseInteraction)
            {
                EditorGUILayout.BeginHorizontal();
                _target.useButton.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", _target.useButton.interaction, typeof(Interaction), true);

                if (_target.useButton.interaction == null)
                {
                    if (GUILayout.Button("Auto-create", autoWidth))
                    {
                        Undo.RegisterSceneUndo("Auto-create interaction");
                        Interaction newInteraction = AdvGame.GetReferences().sceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();

                        newInteraction.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Use");
                        _target.useButton.interaction  = newInteraction;
                    }
                }
                EditorGUILayout.EndHorizontal();

                _target.useIcon = (InteractionIcon)EditorGUILayout.EnumPopup("Icon:", _target.useIcon);
                _target.useButton.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", _target.useButton.playerAction);

                if (_target.useButton.playerAction == PlayerAction.WalkTo)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.useButton.setProximity = EditorGUILayout.BeginToggleGroup("Set minimum distance?", _target.useButton.setProximity);
                    _target.useButton.proximity    = EditorGUILayout.FloatField("Proximity:", _target.useButton.proximity);
                    EditorGUILayout.EndToggleGroup();
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndVertical();


            // Look
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Examine interaction", EditorStyles.boldLabel);

            if (!_target.provideLookInteraction)
            {
                if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RegisterSceneUndo("Create examine interaction");
                    _target.provideLookInteraction = true;
                }
            }
            else
            {
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RegisterSceneUndo("Delete examine interaction");
                    _target.provideLookInteraction = false;
                }
            }

            EditorGUILayout.EndHorizontal();
            if (_target.provideLookInteraction)
            {
                EditorGUILayout.BeginHorizontal();

                _target.lookButton.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", _target.lookButton.interaction, typeof(Interaction), true);

                if (_target.lookButton.interaction == null)
                {
                    if (GUILayout.Button("Auto-create", autoWidth))
                    {
                        Undo.RegisterSceneUndo("Auto-create interaction");
                        Interaction newInteraction = AdvGame.GetReferences().sceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();

                        newInteraction.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Look");
                        _target.lookButton.interaction = newInteraction;
                    }
                }

                EditorGUILayout.EndHorizontal();

                _target.lookButton.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", _target.lookButton.playerAction);

                if (_target.lookButton.playerAction == PlayerAction.WalkTo)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.lookButton.setProximity = EditorGUILayout.BeginToggleGroup("Set minimum distance?", _target.lookButton.setProximity);
                    _target.lookButton.proximity    = EditorGUILayout.FloatField("Proximity:", _target.lookButton.proximity);
                    EditorGUILayout.EndToggleGroup();
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndVertical();

            // Inventory
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Inventory interactions", EditorStyles.boldLabel);

            if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth))
            {
                Undo.RegisterSceneUndo("Create inventory interaction");
                _target.invButtons.Add(new Button());
                _target.provideInvInteraction = true;
            }
            EditorGUILayout.EndHorizontal();

            if (_target.provideInvInteraction)
            {
                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();
                    int           invNumber;

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);
                        }

                        foreach (Button invButton in _target.invButtons)
                        {
                            invNumber = -1;

                            int j = 0;
                            foreach (InvItem _item in inventoryManager.items)
                            {
                                // If an item has been removed, make sure selected variable is still valid
                                if (_item.id == invButton.invID)
                                {
                                    invNumber = j;
                                    break;
                                }

                                j++;
                            }

                            if (invNumber == -1)
                            {
                                // Wasn't found (item was deleted?), so revert to zero
                                Debug.Log("Previously chosen item no longer exists!");
                                invNumber       = 0;
                                invButton.invID = 0;
                            }

                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();

                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());

                            // Re-assign variableID based on PopUp selection
                            invButton.invID = inventoryManager.items[invNumber].id;

                            if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                            {
                                Undo.RegisterSceneUndo("Delete inventory interaction");

                                _target.invButtons.Remove(invButton);

                                if (_target.invButtons.Count == 0)
                                {
                                    _target.provideInvInteraction = false;
                                }

                                break;
                            }

                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();

                            invButton.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", invButton.interaction, typeof(Interaction), true);

                            if (invButton.interaction == null)
                            {
                                if (GUILayout.Button("Auto-create", autoWidth))
                                {
                                    Undo.RegisterSceneUndo("Create Interaction");
                                    Interaction newInteraction = AdvGame.GetReferences().sceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();

                                    newInteraction.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Inv");
                                    invButton.interaction          = newInteraction;
                                }
                            }

                            EditorGUILayout.EndHorizontal();

                            invButton.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", invButton.playerAction);

                            if (invButton.playerAction == PlayerAction.WalkTo)
                            {
                                EditorGUILayout.BeginVertical("Button");
                                invButton.setProximity = EditorGUILayout.BeginToggleGroup("Set minimum distance?", invButton.setProximity);
                                invButton.proximity    = EditorGUILayout.FloatField("Proximity:", invButton.proximity);
                                EditorGUILayout.EndToggleGroup();
                                EditorGUILayout.EndVertical();
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("No inventory items exist!");
                        invNumber = -1;

                        for (int i = 0; i < _target.invButtons.Count; i++)
                        {
                            _target.invButtons[i].invID = -1;
                        }
                    }
                }
                else
                {
                    Debug.LogWarning("An InventoryManager is required to run the game properly - please open the GameManager wizard and set one.");
                }
            }

            EditorGUILayout.EndVertical();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_target);
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        var obj = target as AutoLightingApplyer;

        using (new EditorGUILayout.HorizontalScope())
        {
            obj.enableDirLight = EditorGUILayout.BeginToggleGroup("平行光源色", obj.enableDirLight);
            obj.DirLightColor  = EditorGUILayout.ColorField(obj.DirLightColor);
            EditorGUILayout.EndToggleGroup();
        }

        using (new EditorGUILayout.HorizontalScope())
        {
            obj.enableClearColor = EditorGUILayout.BeginToggleGroup("環境光", obj.enableClearColor);
            obj.selection        = GUILayout.SelectionGrid(obj.selection, new[] { "SkyBox", "単色" }, 2);
            if (obj.selection == 0)
            {
                obj.SkyBoxMaterial = EditorGUILayout.ObjectField(obj.SkyBoxMaterial, typeof(Material), false) as Material;
            }
            else
            {
                obj.SolidClearColor = EditorGUILayout.ColorField(obj.SolidClearColor);
            }
            EditorGUILayout.EndToggleGroup();
        }

        {
            obj.enableFog = EditorGUILayout.BeginToggleGroup("Fog", obj.enableFog);
            obj.FogColor  = EditorGUILayout.ColorField(obj.FogColor);
            obj.FogMode   = (FogMode)EditorGUILayout.EnumPopup(obj.FogMode);
            if (obj.FogMode == FogMode.Linear)
            {
                obj.FogStart = EditorGUILayout.FloatField("Start", obj.FogStart);
                obj.FogEnd   = EditorGUILayout.FloatField("End", obj.FogEnd);
            }
            else
            {
                obj.FogDensity = EditorGUILayout.FloatField("Denstiy", obj.FogDensity);
            }
            EditorGUILayout.EndToggleGroup();
        }


        //GUILayout.Space(20);
        //obj.AutoDestroy = EditorGUILayout.ToggleLeft("AutoDestroy", obj.AutoDestroy);

        GUILayout.Space(10);
        if (GUILayout.Button("現在のシーンに適用"))
        {
            obj.Apply();
        }
        if (GUILayout.Button("今の環境設定値をここに入れる"))
        {
            obj.Store();
        }


        GUILayout.Space(20);


        serializedObject.ApplyModifiedProperties();
    }