예제 #1
0
        // Show Parameters
        private void ShowParameters()
        {
            GUILayout.BeginVertical("Box", GUILayout.ExpandWidth(true));
            GUILayout.Space(5f);

            // Surface index & Minimum decrement to show pain screen
            int surfacesLength = surfaces.Length;

            if (surfacesLength != SurfaceDetector.GetCount)
            {
                surfaces = SurfaceDetector.GetNames;
            }

            surfacesSFo = System.Convert.ToBoolean(GUILayout.Toolbar(System.Convert.ToInt32(surfacesSFo), stateNames, GUILayout.Height(20f)));

            GUILayout.Space(5f);

            if (surfacesSFo)
            {
                int surfacesSize = surfacesArray.arraySize;

                EditorGUILayout.BeginVertical("box");
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical(GUILayout.Width(30f));
                GUILayout.Space(4f);
                GUI.enabled = ASKSettingsWindow.NotBegin(selection);
                bool moveUp = GUILayout.Button("▲", GUILayout.Height(16f));
                GUI.enabled = true;
                GUI.enabled = ASKSettingsWindow.NotEnd(selection, surfacesSize);
                bool moveDown = GUILayout.Button("▼", GUILayout.Height(16f));
                GUI.enabled = true;
                EditorGUILayout.EndVertical();
                //
                GUI.enabled = surfacesSize < surfacesLength;
                bool add = GUILayout.Button("Add Surface", GUILayout.Height(35f));
                GUI.enabled = (surfacesSize > 0);
                bool delete = GUILayout.Button("Remove it", GUILayout.Height(35f));
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();

                if (surfacesSize > 0)
                {
                    GUILayout.Space(5f);
                    selection = GUILayout.SelectionGrid(selection, ASKSettingsWindow.GetNames(surfacesArray, surfacesSize), 1);
                }
                GUILayout.Space(5f);
                EditorGUILayout.EndVertical();

                if (surfacesSize > 0)
                {
                    surfacesElement = surfacesArray.GetArrayElementAtIndex(selection);
                    //
                    indexProp           = surfacesElement.FindPropertyRelative("index");
                    jumpingSFXProp      = surfacesElement.FindPropertyRelative("jumpingSFX");
                    landingSFXProp      = surfacesElement.FindPropertyRelative("landingSFX");
                    footstepSoundsArray = surfacesElement.FindPropertyRelative("footstepSounds");

                    if (surfacesSize != footstepSoundsList.Length)
                    {
                        footstepSoundsList = new ReorderableList[surfacesSize];
                    }

                    if (footstepSoundsList[selection] == null)
                    {
                        footstepSoundsList[selection] = new ReorderableList(serializedObject, footstepSoundsArray, true, true, true, true);
                    }

                    GUILayout.Space(5f);
                    int surfaceIndex = indexProp.intValue;
                    surfaceIndex = (surfaceIndex < surfacesLength) ? surfaceIndex : surfacesLength - 1;
                    surfaceIndex = EditorGUILayout.Popup("Surface Type", surfaceIndex, surfaces);
                    surfacesElement.FindPropertyRelative("name").stringValue = surfaces[surfaceIndex];
                    indexProp.intValue = surfaceIndex;
                    GUILayout.Space(10f);

                    EditorHelper.ShowSFXPropertyAndPlayButton(serializedObject, jumpingSFXProp);
                    EditorHelper.ShowSFXPropertyAndPlayButton(serializedObject, landingSFXProp);
                    EditorHelper.ShowSFXListAndPlayButton(serializedObject, footstepSoundsList[selection], "Footstep Sounds");
                }

                // Actions
                if (add)
                {
                    surfacesArray.InsertArrayElementAtIndex(surfacesSize);
                    surfacesElement = surfacesArray.GetArrayElementAtIndex(surfacesSize);

                    surfacesSize = surfacesArray.arraySize;
                    selection    = (surfacesSize > 1) ? surfacesSize - 1 : 0;

                    surfacesElement.FindPropertyRelative("index").intValue = surfacesSize - 1;
                    surfacesElement.FindPropertyRelative("jumpingSFX").objectReferenceValue = null;
                    surfacesElement.FindPropertyRelative("landingSFX").objectReferenceValue = null;
                    surfacesElement.FindPropertyRelative("footstepSounds").ClearArray();
                }

                if (moveUp)
                {
                    surfacesArray.MoveArrayElement(selection - 1, selection--);
                    return;
                }
                if (moveDown)
                {
                    surfacesArray.MoveArrayElement(selection + 1, selection++);
                    return;
                }
                if (delete)
                {
                    surfacesArray.DeleteArrayElementAtIndex(selection);
                    surfacesSize = surfacesArray.arraySize;
                    selection    = ASKSettingsWindow.NotEnd(selection, surfacesSize) ? selection : surfacesSize - 1;
                    return;
                }
            }
            else
            {
                surfacesElement     = serializedObject.FindProperty("generic");
                jumpingSFXProp      = surfacesElement.FindPropertyRelative("jumpingSFX");
                landingSFXProp      = surfacesElement.FindPropertyRelative("landingSFX");
                footstepSoundsArray = surfacesElement.FindPropertyRelative("footstepSounds");
                //
                EditorHelper.ShowSFXPropertyAndPlayButton(serializedObject, jumpingSFXProp);
                EditorHelper.ShowSFXPropertyAndPlayButton(serializedObject, landingSFXProp);
                EditorHelper.ShowSFXListAndPlayButton(serializedObject, fsGenericList, "Footstep Sounds");
            }

            GUILayout.Space(5f);
            GUILayout.EndVertical();
        }
예제 #2
0
        // Show Surfaces
        private void ShowSurfaces()
        {
            // Surface index & Minimum decrement to show pain screen
            int surfacesLength = surfaces.Length;

            if (surfacesLength != SurfaceDetector.GetCount)
            {
                surfaces = SurfaceDetector.GetNames;
            }

            surfacesSFo = System.Convert.ToBoolean(GUILayout.Toolbar(System.Convert.ToInt32(surfacesSFo), stateNames, GUILayout.Height(20f)));

            GUILayout.Space(5f);

            if (surfacesSFo)
            {
                int surfacesSize = surfacesArray.arraySize;

                EditorGUILayout.BeginVertical("box");
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical(GUILayout.Width(30f));
                GUILayout.Space(4f);
                GUI.enabled = ASKSettingsWindow.NotBegin(selection);
                bool moveUp = GUILayout.Button("▲", GUILayout.Height(16f));
                GUI.enabled = true;
                GUI.enabled = ASKSettingsWindow.NotEnd(selection, surfacesSize);
                bool moveDown = GUILayout.Button("▼", GUILayout.Height(16f));
                GUI.enabled = true;
                EditorGUILayout.EndVertical();
                //
                GUI.enabled = surfacesSize < surfacesLength;
                bool add = GUILayout.Button("Add Surface", GUILayout.Height(35f));
                GUI.enabled = (surfacesSize > 0);
                bool delete = GUILayout.Button("Remove it", GUILayout.Height(35f));
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();

                if (surfacesSize > 0)
                {
                    GUILayout.Space(5f);
                    selection = GUILayout.SelectionGrid(selection, ASKSettingsWindow.GetNames(surfacesArray, surfacesSize), 1);
                }
                GUILayout.Space(5f);
                EditorGUILayout.EndVertical();


                if (surfacesSize > 0)
                {
                    surfacesElement = surfacesArray.GetArrayElementAtIndex(selection);
                    //
                    indexProp       = surfacesElement.FindPropertyRelative("index");
                    hitTextureProp  = surfacesElement.FindPropertyRelative("hitTexture");
                    hitSoundProp    = surfacesElement.FindPropertyRelative("hitSound");
                    hitParticleProp = surfacesElement.FindPropertyRelative("hitParticle");

                    GUILayout.Space(5f);

                    int surfaceIndex = indexProp.intValue;
                    surfaceIndex = (surfaceIndex < surfacesLength) ? surfaceIndex : surfacesLength - 1;
                    surfaceIndex = EditorGUILayout.Popup("Surface Type", surfaceIndex, surfaces);
                    surfacesElement.FindPropertyRelative("name").stringValue = surfaces[surfaceIndex];
                    indexProp.intValue = surfaceIndex;
                    GUILayout.Space(10f);
                    EditorGUILayout.PropertyField(hitTextureProp, EditorHelper.PropertyLabel("Hit Texture"));
                    EditorHelper.ShowSFXPropertyAndPlayButton(serializedObject, hitSoundProp, "Hit SFX");
                    EditorGUILayout.PropertyField(hitParticleProp, EditorHelper.PropertyLabel("Hit Particle"));
                }

                // Actions
                if (add)
                {
                    surfacesArray.InsertArrayElementAtIndex(surfacesSize);
                    surfacesElement = surfacesArray.GetArrayElementAtIndex(surfacesSize);

                    surfacesSize = surfacesArray.arraySize;
                    selection    = (surfacesSize > 1) ? surfacesSize - 1 : 0;

                    surfacesElement.FindPropertyRelative("index").intValue = surfacesSize - 1;
                    surfacesElement.FindPropertyRelative("hitTexture").objectReferenceValue  = null;
                    surfacesElement.FindPropertyRelative("hitSound").objectReferenceValue    = null;
                    surfacesElement.FindPropertyRelative("hitParticle").objectReferenceValue = null;
                }

                if (moveUp)
                {
                    surfacesArray.MoveArrayElement(selection - 1, selection--);
                    return;
                }
                if (moveDown)
                {
                    surfacesArray.MoveArrayElement(selection + 1, selection++);
                    return;
                }
                if (delete)
                {
                    surfacesArray.DeleteArrayElementAtIndex(selection);
                    surfacesSize = surfacesArray.arraySize;
                    selection    = ASKSettingsWindow.NotEnd(selection, surfacesSize) ? selection : surfacesSize - 1;
                    return;
                }
            }
            else
            {
                surfacesElement = serializedObject.FindProperty("generic");
                hitTextureProp  = surfacesElement.FindPropertyRelative("hitTexture");
                hitSoundProp    = surfacesElement.FindPropertyRelative("hitSound");
                hitParticleProp = surfacesElement.FindPropertyRelative("hitParticle");
                //
                EditorGUILayout.PropertyField(hitTextureProp, EditorHelper.PropertyLabel("Hit Texture"));
                EditorHelper.ShowSFXPropertyAndPlayButton(serializedObject, hitSoundProp, "Hit SFX");
                EditorGUILayout.PropertyField(hitParticleProp, EditorHelper.PropertyLabel("Hit Particle"));
            }
        }
예제 #3
0
        // Show LeftSide
        private static void ShowLeftSide()
        {
            int surfacesSize = surfacesArray.arraySize;

            leftScroll = EditorGUILayout.BeginScrollView(leftScroll, "Box", GUILayout.Width(200f), GUILayout.ExpandHeight(true));

            GUILayout.Space(5f);
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Space(25f);
            bool add = GUILayout.Button("Add Surface", GUILayout.Height(35f));

            GUI.enabled = true;
            GUILayout.Space(25f);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5f);

            EditorGUILayout.BeginVertical("Box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            if (surfacesSize > 0)
            {
                selection = GUILayout.SelectionGrid(selection, ASKSettingsWindow.GetNames(surfacesArray, surfacesSize), 1);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginVertical(GUILayout.Width(25f));
            GUILayout.Space(5f);
            GUI.enabled = (surfacesSize > 0);
            bool delete = GUILayout.Button("X");

            GUI.enabled = true;
            GUI.enabled = ASKSettingsWindow.NotBegin(selection);
            GUILayout.Space(15f);
            bool moveUp = GUILayout.Button("▲", GUILayout.Height(30f));

            GUI.enabled = true;
            GUI.enabled = ASKSettingsWindow.NotEnd(selection, surfacesSize);
            bool moveDown = GUILayout.Button("▼", GUILayout.Height(30f));

            GUI.enabled = true;
            EditorGUILayout.EndVertical();


            if (add)
            {
                surfacesArray.InsertArrayElementAtIndex(surfacesSize);
                surfacesElement = surfacesArray.GetArrayElementAtIndex(surfacesSize);

                surfacesSize = surfacesArray.arraySize;
                selection    = (surfacesSize > 1) ? surfacesSize - 1 : 0;

                surfacesElement.FindPropertyRelative("name").stringValue = "New Surface " + surfacesSize;
                surfacesElement.FindPropertyRelative("materials").ClearArray();
                surfacesElement.FindPropertyRelative("textures").ClearArray();
            }

            if (moveUp)
            {
                surfacesArray.MoveArrayElement(selection - 1, selection--);
                return;
            }
            if (moveDown)
            {
                surfacesArray.MoveArrayElement(selection + 1, selection++);
                return;
            }
            if (delete)
            {
                surfacesArray.DeleteArrayElementAtIndex(selection);
                surfacesSize = surfacesArray.arraySize;
                selection    = ASKSettingsWindow.NotEnd(selection, surfacesSize) ? selection : surfacesSize - 1;
                return;
            }
        }
예제 #4
0
        // Show Tab
        private static void ShowTab(ref SerializedProperty array, ref SerializedProperty element, float space)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(100f);
            bool add = GUILayout.Button("Add " + ((currentTab == 0) ? "Mesh Material" : "Terrain Texture"), GUILayout.Height(20f));

            GUILayout.Space(100f);
            GUILayout.EndHorizontal();

            array = surfacesElement.FindPropertyRelative(currentTab == 0 ? "materials" : "textures");
            int materialsSize = array.arraySize;

            if (add)
            {
                array.InsertArrayElementAtIndex(materialsSize);
                element = array.GetArrayElementAtIndex(materialsSize);
                element.objectReferenceValue = null;
                materialsSize = array.arraySize;
            }

            GUILayout.Space(5f);
            rightScroll = EditorGUILayout.BeginScrollView(rightScroll, "Box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.Space(5f);
            byte cells = 0;

            for (int i = 0; i < materialsSize; i++)
            {
                element = array.GetArrayElementAtIndex(i);

                if (cells == 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(space);
                }

                GUILayout.BeginHorizontal("Box", GUILayout.MaxWidth(100f));
                GUILayout.BeginVertical();

                GUILayout.Label(AssetPreview.GetAssetPreview(element.objectReferenceValue), GUILayout.Width(95f), GUILayout.Height(95f));

                GUILayout.Space(-95f);

                EditorGUILayout.PropertyField(element, GUIContent.none, GUILayout.Width(95f), GUILayout.Height(18f));

                GUILayout.BeginHorizontal();
                bool mUp = ASKSettingsWindow.NotBegin(i) ? GUILayout.Button("◄", GUILayout.Width(22f), GUILayout.Height(20f)) : false;
                GUILayout.Space(ASKSettingsWindow.NotBegin(i) ? 47f : 76f);
                bool mDown = ASKSettingsWindow.NotEnd(i, materialsSize) ? GUILayout.Button("►", GUILayout.Width(22f), GUILayout.Height(20f)) : false;
                GUILayout.EndHorizontal();

                GUILayout.Space(materialsSize > 1 ? 28f : 48f);

                GUILayout.BeginHorizontal();
                GUILayout.Space(77f);
                bool mDel = GUILayout.Button("X", GUILayout.Width(18f), GUILayout.Height(16f));
                GUILayout.EndHorizontal();

                GUILayout.Space(4f);

                GUILayout.EndVertical();
                GUILayout.EndHorizontal();


                if (mUp)
                {
                    array.MoveArrayElement(i - 1, i);
                    return;
                }
                if (mDown)
                {
                    array.MoveArrayElement(i + 1, i);
                    return;
                }

                if (mDel)
                {
                    element.objectReferenceValue = null;
                    array.DeleteArrayElementAtIndex(i);
                    return;
                }

                cells++;
                int maxCells = Mathf.RoundToInt(ASKSettingsWindow.width / 170f);

                if (cells == maxCells || i == materialsSize - 1)
                {
                    GUILayout.Space(5f);
                    GUILayout.EndHorizontal();
                    cells = 0;
                }
            }
            GUILayout.Space(5f);
            EditorGUILayout.EndScrollView();
        }
예제 #5
0
        // Show LeftAxesSide
        private static void ShowLeftAxesSide()
        {
            int axesDatabaseSize = axesDatabaseArray.arraySize;

            leftScroll = EditorGUILayout.BeginScrollView(leftScroll, "Box", GUILayout.Width(200f), GUILayout.ExpandHeight(true));

            GUILayout.Space(5f);
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Space(25f);
            bool add = GUILayout.Button("Add Axis", GUILayout.Height(35f));

            GUI.enabled = true;
            GUILayout.Space(25f);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5f);

            EditorGUILayout.BeginVertical("Box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            if (axesDatabaseSize > 0)
            {
                axesSel = GUILayout.SelectionGrid(axesSel, ASKSettingsWindow.GetNames(axesDatabaseArray, axesDatabaseSize), 1);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginVertical(GUILayout.Width(25f));
            GUILayout.Space(5f);
            GUI.enabled = (axesDatabaseSize > 0);
            bool delete = GUILayout.Button("X");

            GUI.enabled = true;
            GUI.enabled = ASKSettingsWindow.NotBegin(axesSel);
            GUILayout.Space(15f);
            bool moveUp = GUILayout.Button("▲", GUILayout.Height(30f));

            GUI.enabled = true;
            GUI.enabled = ASKSettingsWindow.NotEnd(axesSel, axesDatabaseSize);
            bool moveDown = GUILayout.Button("▼", GUILayout.Height(30f));

            GUI.enabled = true;
            EditorGUILayout.EndVertical();


            if (add)
            {
                axesDatabaseArray.InsertArrayElementAtIndex(axesDatabaseSize);
                SerializedProperty axesDatabaseElement = axesDatabaseArray.GetArrayElementAtIndex(axesDatabaseSize);

                axesDatabaseSize = axesDatabaseArray.arraySize;
                axesSel          = (axesDatabaseSize > 1) ? axesSel : 0;

                axesDatabaseElement.FindPropertyRelative("name").stringValue    = "New Axis " + axesDatabaseSize;
                axesDatabaseElement.FindPropertyRelative("type").enumValueIndex = 0;
                axesDatabaseElement.FindPropertyRelative("unityAxes").ClearArray();
                axesDatabaseElement.FindPropertyRelative("customKeys").ClearArray();
                axesDatabaseElement.FindPropertyRelative("normalize").boolValue = false;
            }

            if (moveUp)
            {
                axesDatabaseArray.MoveArrayElement(axesSel - 1, axesSel--);
                return;
            }
            if (moveDown)
            {
                axesDatabaseArray.MoveArrayElement(axesSel + 1, axesSel++);
                return;
            }
            if (delete)
            {
                axesDatabaseArray.DeleteArrayElementAtIndex(axesSel);
                axesDatabaseSize = axesDatabaseArray.arraySize;
                axesSel          = ASKSettingsWindow.NotEnd(axesSel, axesDatabaseSize) ? axesSel : axesDatabaseSize - 1;
                return;
            }
        }