public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
            {
                Material material = (Material)editor.target;

                Init(prop.displayName);


                //Read settings
                CurvedWorld.BEND_TYPE bendType;
                int  bendID;
                bool normalTransform;

                EditorUtilities.GetBendSettingsFromVector(prop.vectorValue, out bendType, out bendID, out normalTransform);

                //Make sure keywords are assinged correctly
                if ((material.IsKeywordEnabled(EditorUtilities.GetKeywordName(bendType)) == false || material.IsKeywordEnabled(EditorUtilities.GetKeywordName(bendID)) == false) &&
                    File.Exists(EditorUtilities.GetBendFileLocation(bendType, bendID, EditorUtilities.EXTENSTION.cginc)))
                {
                    EditorUtilities.UpdateMaterialKeyWords(material, bendType, bendID, normalTransform);

                    if (CurvedWorldEditorWindow.activeWindow != null && CurvedWorldEditorWindow.activeWindow.gTab == CurvedWorldEditorWindow.TAB.RenderersOverview)
                    {
                        CurvedWorldEditorWindow.activeWindow.RebuildSceneShadersOverview();
                        CurvedWorldEditorWindow.activeWindow.Repaint();
                    }
                }
                if (normalTransform != material.IsKeywordEnabled(EditorUtilities.shaderKeywordName_BendTransformNormal))
                {
                    if (material.IsKeywordEnabled(EditorUtilities.shaderKeywordName_BendTransformNormal))
                    {
                        normalTransform = true;
                    }
                    else
                    {
                        normalTransform = false;
                    }

                    prop.vectorValue = new Vector4((int)bendType, bendID, (hasNormalTransform ? (normalTransform ? 1 : 0) : 0), 0);

                    if (CurvedWorldEditorWindow.activeWindow != null && CurvedWorldEditorWindow.activeWindow.gTab == CurvedWorldEditorWindow.TAB.RenderersOverview)
                    {
                        CurvedWorldEditorWindow.activeWindow.RebuildSceneShadersOverview();
                        CurvedWorldEditorWindow.activeWindow.Repaint();
                    }
                }



                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = prop.hasMixedValue;

                position.height = 18;
                using (new AmazingAssets.EditorGUIUtility.EditorGUIUtilityLabelWidth(0))
                {
                    position.height = 18;

                    bendType = (CurvedWorld.BEND_TYPE)EditorGUI.Popup(new Rect(position.xMin, position.yMin, position.width - 20, position.height), " ", (int)bendType, EditorUtilities.bendTypesNamesForMenu);
                    EditorGUI.LabelField(new Rect(position.xMin, position.yMin, position.width - 20, position.height), "Bend Type", EditorUtilities.GetBendTypeNameInfo(bendType).forLable, EditorStyles.popup);


                    if (GUI.Button(new Rect(position.xMax - 20, position.yMin, 20, position.height), "≡"))
                    {
                        GenericMenu menu = new GenericMenu();

                        menu.AddItem(new GUIContent("Find Controller"), false, EditorUtilities.CallbackFindController, (int)bendType + "_" + bendID);
                        menu.AddItem(new GUIContent("Editor Window"), false, EditorUtilities.CallbackOpenCurvedWorldSettingsWindow, (int)bendType + "_" + bendID);
                        menu.AddItem(new GUIContent("Curved World Keywords"), false, EditorUtilities.CallbackAnalyzeShaderCurvedWorldKeywords, material.shader);

                        menu.AddItem(new GUIContent("Reimport Shader"), false, EditorUtilities.CallbackReimportShader, material.shader);


                        menu.ShowAsContext();
                    }


                    position.yMin  += 20;
                    position.height = 18;
                    bendID          = EditorGUI.IntSlider(position, "Bend ID", bendID, 1, EditorUtilities.MAX_SUPPORTED_BEND_IDS);

                    if (hasNormalTransform)
                    {
                        position.yMin  += 20;
                        position.height = 18;
                        normalTransform = EditorGUI.Toggle(position, "Normal Transform", normalTransform);
                    }
                }


                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    if (bendID < 1)
                    {
                        bendID = 1;
                    }

                    // Set the new value if it has changed
                    prop.vectorValue = new Vector4((int)bendType, bendID, (hasNormalTransform ? (normalTransform ? 1 : 0) : 0), 0);

                    if (File.Exists(EditorUtilities.GetBendFileLocation(bendType, bendID, EditorUtilities.EXTENSTION.cginc)))
                    {
                        Undo.RecordObjects(editor.targets, "Change Keywords");

                        foreach (Material mat in editor.targets)
                        {
                            EditorUtilities.UpdateMaterialKeyWords(mat, bendType, bendID, normalTransform);
                        }
                    }
                    else
                    {
                        //If file does not exist still adjust keyword for normal transformation
                        foreach (Material mat in editor.targets)
                        {
                            if (normalTransform)
                            {
                                mat.EnableKeyword(EditorUtilities.shaderKeywordName_BendTransformNormal);
                            }
                            else
                            {
                                mat.DisableKeyword(EditorUtilities.shaderKeywordName_BendTransformNormal);
                            }
                        }
                    }

                    if (CurvedWorldEditorWindow.activeWindow != null && CurvedWorldEditorWindow.activeWindow.gTab == CurvedWorldEditorWindow.TAB.RenderersOverview)
                    {
                        CurvedWorldEditorWindow.activeWindow.RebuildSceneShadersOverview();
                        CurvedWorldEditorWindow.activeWindow.Repaint();
                    }
                }



                if (shaderSupportedBendTypes.Contains(bendType) == false || shaderSupportedBendIDs.Contains(bendID) == false ||
                    File.Exists(EditorUtilities.GetBendFileLocation(bendType, bendID, EditorUtilities.EXTENSTION.cginc)) == false)
                {
                    position.yMin  += 20;
                    position.height = 36;
                    EditorGUI.HelpBox(position, "Missing Keywords!", MessageType.Error);

                    if (GUI.Button(new Rect(position.xMax - 64 - 5, position.yMin + 9, 64, 18), "Actions"))
                    {
                        updateBendType        = bendType;
                        updateBendID          = bendID;
                        updateNormalTransform = normalTransform;
                        updateMaterial        = material;
                        updateMaterialEditor  = editor;

                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Update Shader"), false, CallBackUpdateShader);
                        menu.ShowAsContext();
                    }
                }
            }
        Vector2 DrawUnitList(float startX, float startY, List <UnitTower> towerList)
        {
            float width = 260;

            if (minimiseList)
            {
                width = 60;
            }

            if (!minimiseList)
            {
                if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up"))
                {
                    if (selectID > 0)
                    {
                        UnitTower tower = towerList[selectID];
                        towerList[selectID]     = towerList[selectID - 1];
                        towerList[selectID - 1] = tower;
                        selectID -= 1;

                        if (selectID * 35 < scrollPos1.y)
                        {
                            scrollPos1.y = selectID * 35;
                        }
                    }
                }
                if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down"))
                {
                    if (selectID < towerList.Count - 1)
                    {
                        UnitTower tower = towerList[selectID];
                        towerList[selectID]     = towerList[selectID + 1];
                        towerList[selectID + 1] = tower;
                        selectID += 1;

                        if (listVisibleRect.height - 35 < selectID * 35)
                        {
                            scrollPos1.y = (selectID + 1) * 35 - listVisibleRect.height + 5;
                        }
                    }
                }
            }


            listVisibleRect = new Rect(startX, startY, width + 15, window.position.height - startY - 5);
            listContentRect = new Rect(startX, startY, width, towerList.Count * 35 + 5);

            GUI.color = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(listVisibleRect, "");
            GUI.color = Color.white;

            scrollPos1 = GUI.BeginScrollView(listVisibleRect, scrollPos1, listContentRect);


            startY += 5;      startX += 5;

            for (int i = 0; i < towerList.Count; i++)
            {
                EditorUtilities.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), towerList[i].iconSprite);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), ""))
                    {
                        SelectTower(i);
                    }
                    GUI.color = Color.white;

                    continue;
                }



                if (selectID == i)
                {
                    GUI.color = new Color(0, 1f, 1f, 1f);
                }
                if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150, 30), towerList[i].unitName))
                {
                    SelectTower(i);
                }
                GUI.color = Color.white;

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm"))
                    {
                        if (selectID >= deleteID)
                        {
                            SelectTower(Mathf.Max(0, selectID - 1));
                        }
                        EditorDBManager.RemoveTower(deleteID);
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            return(new Vector2(startX + width, startY));
        }
 public override void OnInspectorGUI()
 {
     EditorUtilities.DrawHeaderLabel("Core Property");
     PropertyField(Amplitude);
     PropertyField(Speed);
 }
 public override void OnInspectorGUI()
 {
     EditorUtilities.DrawHeaderLabel("Core Property");
     PropertyField(pixelSize);
     PropertyField(gridWidth);
 }
Exemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();
            cont = new GUIContent("Use Tower Weapon:", "Check to have use the assigned weapon of the selected tower. When this is enabled, player cannot switch weapon.");
            instance.useTowerWeapon = EditorGUILayout.Toggle(cont, instance.useTowerWeapon);


            cont = new GUIContent("Aim Sensitivity:", "Mouse sensitivity when aiming in fps mode");
            instance.aimSensitivity = EditorGUILayout.FloatField(cont, instance.aimSensitivity);

            cont  = new GUIContent("Recoil Mode:", "The way shoot recoil works");
            contL = new GUIContent[recoilModeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(recoilModeLabel[i], recoilModeTooltip[i]);
            }
            instance.recoilMode = EditorGUILayout.Popup(cont, instance.recoilMode, contL);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPivotTransform = EditorGUILayout.Foldout(showPivotTransform, "Show Pivot Transforms & Camera");
            EditorGUILayout.EndHorizontal();
            if (showPivotTransform)
            {
                cont = new GUIContent("Weapon Pivot:", "The pivot transform of the weapon object.");
                instance.weaponPivot = (Transform)EditorGUILayout.ObjectField(cont, instance.weaponPivot, typeof(Transform), true);

                cont = new GUIContent("Camera Pivot:", "The pivot transform of the camera");
                instance.cameraPivot = (Transform)EditorGUILayout.ObjectField(cont, instance.cameraPivot, typeof(Transform), true);

                cont          = new GUIContent("Camera Transform:", "The transform which contains the fps camera component");
                instance.camT = (Transform)EditorGUILayout.ObjectField(cont, instance.camT, typeof(Transform), true);
            }


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showWeaponList = EditorGUILayout.Foldout(showWeaponList, "Show Weapon List");
            EditorGUILayout.EndHorizontal();
            if (showWeaponList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < weaponList.Count; i++)
                    {
                        instance.unavailableIDList.Add(weaponList[i].prefabID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                //scrollPosition = GUILayout.BeginScrollView (scrollPosition);

                for (int i = 0; i < weaponList.Count; i++)
                {
                    FPSWeapon weapon = weaponList[i];

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, weapon.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(weapon.name, GUILayout.ExpandWidth(false));

                    bool flag = !instance.unavailableIDList.Contains(weapon.prefabID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                           //switch it around in runtime
                    }
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the weapon in this level"), flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableIDList.Remove(weapon.prefabID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(weapon.prefabID))
                            {
                                instance.unavailableIDList.Add(weapon.prefabID);
                            }
                        }
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }


            EditorGUILayout.Space();


            if (GUILayout.Button("Open FPSWeaponEditor"))
            {
                //FPSWeaponEditorWindow.Init();
            }
            EditorGUILayout.Space();



            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemplo n.º 6
0
        private void DrawInputConditionListItems(Rect rect, int index, bool isActive, bool isFocused)
        {
            SerializedProperty element = inputConditionList.serializedProperty.GetArrayElementAtIndex(index);

            EditorUtilities.DrawInputConditionItem(mappingType, element, index, rect, infoBoxStyle);
        }
Exemplo n.º 7
0
        private void DrawOutputChangeListItems(Rect rect, int index, bool isActive, bool isFocused)
        {
            SerializedProperty element = outputChangeList.serializedProperty.GetArrayElementAtIndex(index);

            EditorUtilities.DrawOutputChangeItem(index, mappingType, element, rect, infoBoxStyle);
        }
Exemplo n.º 8
0
 public void ExecuteMoveLineDown(object sender, ExecutedRoutedEventArgs e) => IfNotReadOnly(() => EditorUtilities.MoveSegmentDown(EditBox));
Exemplo n.º 9
0
 public void ExecuteConvertSelectionToList(object sender, ExecutedRoutedEventArgs e) => IfNotReadOnly(() => EditorUtilities.ConvertSelectionToList(EditBox));
        public override void OnInspectorGUI()
        {
            // Update the serializedProperty - always do this in the beginning of OnInspectorGUI
            serializedObject.Update();

            EditorGUI.indentLevel = 0;
            EditorUtilities.FoldoutHeader("Character Settings", m_CharacterHeight);

            if (m_CharacterHeight.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(m_CharacterHeight, new UnityEngine.GUIContent("Height (m)"));
                EditorGUILayout.PropertyField(m_CharacterShoulderWidth, new UnityEngine.GUIContent("Shoulder Width (m)"));
                EditorGUILayout.PropertyField(m_CharacterWeight, new UnityEngine.GUIContent("Base Weight (kg)"));

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(m_AllowJump);
                EditorGUILayout.PropertyField(m_AllowRun);

                using (new EditorGUILayout.VerticalScope(Styling.background))
                {
                    EditorGUI.indentLevel = 0;
                    EditorGUILayout.PropertyField(m_AllowCrouch);

                    if (m_AllowCrouch.boolValue)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(m_CrouchingHeight, new UnityEngine.GUIContent("Crouching Height (m)"));
                        EditorGUILayout.PropertyField(m_CrouchingSpeed);
                        EditorGUI.indentLevel--;
                    }
                }

                EditorGUI.indentLevel = 1;
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(m_MaxWeight, new UnityEngine.GUIContent("Max Weight (kg)"));
                EditorGUILayout.PropertyField(m_MaxSpeedLoss);

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(m_SlopeLimit);
                EditorGUILayout.PropertyField(m_StepOffset);
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.FoldoutHeader("Movement Settings", m_WalkingForce);

            if (m_WalkingForce.isExpanded)
            {
                EditorGUI.indentLevel = 1;

                EditorGUILayout.PropertyField(m_WalkingForce);
                if (m_AllowCrouch.boolValue)
                {
                    EditorGUILayout.PropertyField(m_CrouchForce);
                }
                if (m_AllowRun.boolValue)
                {
                    EditorGUILayout.PropertyField(m_RunMultiplier);
                }

                EditorGUILayout.Space();
                if (m_AllowJump.boolValue)
                {
                    EditorGUILayout.PropertyField(m_JumpForce);
                    EditorGUILayout.PropertyField(m_JumpDelay);
                }

                EditorGUILayout.PropertyField(m_AirControlPercent);

                EditorGUI.indentLevel = 0;
                using (new EditorGUILayout.VerticalScope(Styling.background))
                {
                    EditorUtilities.SimpleFoldoutHeader("Fall Settings", m_HeightThreshold);

                    if (m_HeightThreshold.isExpanded)
                    {
                        EditorGUI.indentLevel = 2;
                        EditorGUILayout.PropertyField(m_HeightThreshold);
                        EditorGUILayout.PropertyField(m_DamageMultiplier);
                    }
                    EditorGUI.indentLevel = 1;
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.FoldoutHeader("Camera Settings", m_CameraController);

            if (m_CameraController.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(m_MainCamera);
                EditorGUILayout.PropertyField(m_Smoothness);

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(m_YawSensitivity, new UnityEngine.GUIContent("Yaw Sensitivity (X-Pivot)"));
                EditorGUILayout.PropertyField(m_PitchSensitivity, new UnityEngine.GUIContent("Pitch Sensitivity (Y-Pivot)"));

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_AimingYawSensitivity, new UnityEngine.GUIContent("Aiming Yaw Sensitivity (X-Pivot)"));
                EditorGUILayout.PropertyField(m_AimingPitchSensitivity, new UnityEngine.GUIContent("Aiming Pitch Sensitivity (Y-Pivot)"));

                EditorGUI.indentLevel = 0;
                using (new EditorGUILayout.VerticalScope(Styling.background))
                {
                    EditorGUILayout.PropertyField(m_LimitPitchRotation);

                    if (m_LimitPitchRotation.boolValue)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(m_PitchLimit);
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel = 1;
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Climbing", m_Ladder);

            if (m_Ladder.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_Ladder.boolValue))
                {
                    EditorGUILayout.PropertyField(m_ClimbingSpeed);
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Sliding", m_Sliding);

            if (m_Sliding.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_Sliding.boolValue))
                {
                    EditorGUILayout.PropertyField(m_SlidingThrust);
                    if (m_SlidingThrust.floatValue <= m_CrouchForce.floatValue)
                    {
                        EditorGUILayout.HelpBox("Sliding Thrust should be greater than Crouch Force", MessageType.Warning);
                    }

                    EditorGUILayout.PropertyField(m_SlidingDistance);
                    EditorGUILayout.PropertyField(m_DelayToGetUp);
                    EditorGUILayout.PropertyField(m_StandAfterSliding);
                    EditorGUILayout.PropertyField(m_SlidingSlopeLimit);

                    EditorGUI.indentLevel = 0;
                    using (new EditorGUILayout.VerticalScope(Styling.background))
                    {
                        EditorGUILayout.PropertyField(m_OverrideCameraPitchLimit, new UnityEngine.GUIContent("Override Pitch Limit"));
                        if (m_OverrideCameraPitchLimit.boolValue)
                        {
                            EditorGUI.indentLevel++;
                            EditorGUILayout.PropertyField(m_SlidingCameraPitch);
                            EditorGUI.indentLevel--;
                        }
                    }
                    EditorGUI.indentLevel = 1;
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Stamina", m_Stamina);

            if (m_Stamina.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_Stamina.boolValue))
                {
                    EditorGUILayout.PropertyField(m_MaxStaminaAmount, new UnityEngine.GUIContent("Stamina Amount"));
                    EditorGUILayout.PropertyField(m_IncrementRatio, new UnityEngine.GUIContent("Increment Rate"));
                    EditorGUILayout.PropertyField(m_DecrementRatio, new UnityEngine.GUIContent("Decrement Rate"));

                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(m_WeightAffectSpeed, new UnityEngine.GUIContent("Extra Weight Affect Speed"));
                    EditorGUILayout.PropertyField(m_WeightAffectJump, new UnityEngine.GUIContent("Extra Weight Affect Jump"));

                    EditorGUILayout.Space();
                    using (new EditorGUILayout.VerticalScope(Styling.background))
                    {
                        EditorGUI.indentLevel = 0;
                        EditorGUILayout.PropertyField(m_Fatigue);

                        if (m_Fatigue.boolValue)
                        {
                            EditorGUI.indentLevel++;
                            EditorGUILayout.PropertyField(m_StaminaThreshold);
                            EditorGUILayout.PropertyField(m_BreathSound);
                            EditorGUILayout.PropertyField(m_MaximumBreathVolume);
                            EditorGUI.indentLevel--;
                        }
                    }
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Parkour", m_Vault);

            if (m_Vault.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_Vault.boolValue))
                {
                    EditorGUILayout.PropertyField(m_AffectedLayers);
                    EditorGUILayout.PropertyField(m_AllowWallJumping);
                    EditorGUILayout.PropertyField(m_VaultAnimationCurve);
                    EditorGUILayout.PropertyField(m_VaultDuration);
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Footsteps", m_Footsteps);

            if (m_Footsteps.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_Footsteps.boolValue))
                {
                    EditorGUILayout.PropertyField(m_WalkingVolume);
                    EditorGUILayout.PropertyField(m_RunningVolume);
                    EditorGUILayout.PropertyField(m_CrouchVolume);

                    EditorGUILayout.Space();
                    EditorGUI.indentLevel = 0;
                    using (new EditorGUILayout.VerticalScope(Styling.background))
                    {
                        EditorGUILayout.PropertyField(m_AutomaticallyCalculateIntervals);

                        if (!m_AutomaticallyCalculateIntervals.boolValue)
                        {
                            EditorGUI.indentLevel++;
                            EditorGUILayout.PropertyField(m_WalkingBaseInterval);
                            EditorGUILayout.PropertyField(m_RunningBaseInterval);
                            EditorGUILayout.PropertyField(m_CrouchBaseInterval);
                            EditorGUILayout.PropertyField(m_ClimbingInterval);
                            EditorGUI.indentLevel--;
                        }
                    }

                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(m_JumpVolume);
                    EditorGUILayout.PropertyField(m_LandingVolume);
                    EditorGUILayout.PropertyField(m_SlidingVolume);

                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(m_StandingUpSound);
                    EditorGUILayout.PropertyField(m_CrouchingDownSound);
                    EditorGUILayout.PropertyField(m_CrouchingVolume);
                }
            }

            EditorUtilities.DrawSplitter();

            //Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 11
0
 private bool IfNotReadOnly(Func <bool> action) => EditBox.IsReadOnly ? EditorUtilities.ErrorBeep() : action();
Exemplo n.º 12
0
        public void DrawProjectSelector()
        {
            var darkLabel = ME.Utilities.CacheStyle("FlowEditor.DataSelection.Styles", "DarkLabel", (name) => {
                var style       = new GUIStyle(FlowSystemEditorWindow.defaultSkin.FindStyle(name));
                style.alignment = TextAnchor.MiddleLeft;
                return(style);
            });

            var headerStyle = new GUIStyle("LODLevelNotifyText");

            headerStyle.normal.textColor = EditorGUIUtility.isProSkin == true ? Color.white : Color.black;
            headerStyle.fontSize         = 18;
            headerStyle.alignment        = TextAnchor.MiddleCenter;

            GUILayoutExt.LabelWithShadow(string.Format("UI.Windows Flow Extension v{0}", VersionInfo.BUNDLE_VERSION), headerStyle);

            GUILayout.Space(10f);

            GUILayout.Label("Open one of your projects:", darkLabel);

            var backStyle = new GUIStyle("sv_iconselector_labelselection");

            var skin = GUI.skin;

            GUI.skin = FlowSystemEditorWindow.defaultSkin;
            this.dataSelectionScroll = GUILayout.BeginScrollView(this.dataSelectionScroll, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, backStyle);
            {
                GUI.skin = skin;

                this.scannedData = EditorUtilities.GetAssetsOfType <FlowData>(useCache: false);

                if (this.scannedData.Length == 0)
                {
                    var center = new GUIStyle(darkLabel);
                    center.fixedWidth    = 0f;
                    center.fixedHeight   = 0f;
                    center.stretchWidth  = true;
                    center.stretchHeight = true;
                    center.alignment     = TextAnchor.MiddleCenter;
                    center.wordWrap      = true;

                    GUILayout.Label("No projects were found. Create a new one by Right-Click on any folder in Project View and choose `Create->UI.Windows->Flow->Graph` option.", center);
                }
                else
                {
                    var buttonStyle = new GUIStyle("flow node 1 on");
                    buttonStyle.alignment        = TextAnchor.MiddleLeft;
                    buttonStyle.padding          = new RectOffset(15, 15, 15, 15);
                    buttonStyle.margin           = new RectOffset(2, 2, 2, 2);
                    buttonStyle.overflow         = new RectOffset();
                    buttonStyle.contentOffset    = Vector2.zero;
                    buttonStyle.fixedWidth       = 0f;
                    buttonStyle.fixedHeight      = 0f;
                    buttonStyle.stretchWidth     = true;
                    buttonStyle.stretchHeight    = false;
                    buttonStyle.normal.textColor = Color.white;
                    buttonStyle.fontSize         = 12;
                    buttonStyle.richText         = true;

                    var buttonStyleSelected = new GUIStyle(buttonStyle);
                    buttonStyle.normal.background = null;
                    buttonStyle.normal.textColor  = Color.black;

                    this.scannedData = this.scannedData.OrderByDescending((data) => (data != null ? data.lastModifiedUnix : 0)).ToArray();

                    foreach (var data in this.scannedData)
                    {
                        if (data == null)
                        {
                            continue;
                        }

                        var isSelected = (this.cachedData == data);

                        var title = data.name + "\n";
                        title += string.Format("<color={1}><size=10>Modified: {0}</size></color>\n", data.lastModified, isSelected == true ? "#ccc" : "#999");
                        title += string.Format("<color={1}><size=10>Version: {0}</size></color>", data.version, isSelected == true ? "#ccc" : "#999");

                        if (GUILayout.Button(title, isSelected ? buttonStyleSelected : buttonStyle) == true)
                        {
                            this.cachedData = data;
                        }
                    }
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndScrollView();

            GUILayout.Space(10f);

            GUILayout.Label("Or select the project file:", darkLabel);

            this.cachedData = GUILayoutExt.ObjectField <FlowData>(this.cachedData, false, FlowSystemEditorWindow.defaultSkin.FindStyle("ObjectField"));

            CustomGUI.Splitter();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Create Project...", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                {
                    this.state = State.NewProject;
                }

                GUILayout.FlexibleSpace();

                var oldState = GUI.enabled;
                GUI.enabled = oldState && this.cachedData != null;

                if (this.cachedData != null && this.cachedData.version < VersionInfo.BUNDLE_VERSION)
                {
                    // Need to upgrade

                    if (GUILayout.Button("Upgrade to " + VersionInfo.BUNDLE_VERSION, FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                    {
                        FlowUpdater.Run(this.cachedData);
                    }
                }
                else if (this.cachedData != null && this.cachedData.version > VersionInfo.BUNDLE_VERSION)
                {
                    var info = string.Format(
                        "Selected Project has `{0}` version while UI.Windows System has `{1}` version number. Click here to download a new version.",
                        this.cachedData.version,
                        VersionInfo.BUNDLE_VERSION
                        );

                    if (GUILayout.Button(new GUIContent(info, new GUIStyle("CN EntryWarn").normal.background), EditorStyles.helpBox, GUILayout.Height(40f)) == true)
                    {
                        Application.OpenURL(VersionInfo.DOWNLOAD_LINK);
                    }
                }
                else
                {
                    if (GUILayout.Button("Open", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(40f)) == true)
                    {
                        FlowSystem.SetData(this.cachedData);
                    }
                }

                GUI.enabled = oldState;
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 13
0
        public void DrawNewProject()
        {
            var hasErrors = false;

            var darkLabel = ME.Utilities.CacheStyle("FlowEditor.DataSelection.Styles", "DarkLabel", (name) => {
                var style       = new GUIStyle(FlowSystemEditorWindow.defaultSkin.FindStyle(name));
                style.alignment = TextAnchor.MiddleLeft;
                return(style);
            });

            GUILayout.Label("1. Select the project folder:", darkLabel);
            EditorGUILayout.HelpBox("It is strongly recommended to create new project in Resources folder!", MessageType.Warning);
            GUILayout.BeginHorizontal(GUILayout.Height(30f));
            {
                this.projectFolder = EditorGUILayout.TextField(this.projectFolder, this.skin.textField).UppercaseWords();
                if (GUILayout.Button("...", this.skin.button, GUILayout.Width(35f)) == true)
                {
                    var path = EditorUtility.SaveFolderPanel("Select Empty Project Folder", "Assets/", "").Trim();
                    if (string.IsNullOrEmpty(path) == false)
                    {
                        var splitted = path.Split(new string[] { Application.dataPath }, StringSplitOptions.None);
                        if (splitted.Length > 1)
                        {
                            path = "Assets" + splitted[1];
                        }

                        this.projectFolder = path;
                    }
                }
            }
            GUILayout.EndHorizontal();

            // Test it
            if (Directory.Exists(this.projectFolder) == true &&
                (Directory.GetFiles(this.projectFolder).Count() > 0 ||
                 Directory.GetDirectories(this.projectFolder).Count() > 0))
            {
                EditorGUILayout.HelpBox("Directory should not exists or must be empty.", MessageType.Error);
                hasErrors = true;
            }

            if (this.projectNamespaceAuto == true || string.IsNullOrEmpty(this.projectNamespace) == true)
            {
                this.projectNamespace = this.projectFolder.Split('/').Last().Trim() + ".UI";
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("2. Project namespace:", darkLabel);
                GUILayout.FlexibleSpace();
                this.projectNamespaceAuto = GUILayout.Toggle(this.projectNamespaceAuto, "Automatic");
            }
            GUILayout.EndHorizontal();

            var oldState = GUI.enabled;

            GUILayout.BeginHorizontal(GUILayout.Height(30f));
            {
                GUI.enabled           = oldState && !this.projectNamespaceAuto;
                this.projectNamespace = EditorGUILayout.TextField(this.projectNamespace, this.skin.textField);
                GUI.enabled           = oldState;
            }
            GUILayout.EndHorizontal();

            // Test it
            //var type = Type.GetType("Assembly-CSharp", throwOnError: true, ignoreCase: true);
            string assemblyName = "Assembly-CSharp";

            var asm = AppDomain.CurrentDomain.GetAssemblies().Where((item) => {
                var name = item.FullName.ToLower().Trim();
                return(name.StartsWith(assemblyName.ToLower() + ","));
            }).FirstOrDefault();

            if (asm != null)
            {
                var contains = asm.GetTypes().Any((type) => {
                    return(type.Namespace != null && type.Namespace.ToLower().Trim() == this.projectNamespace.ToLower().Trim());
                });

                if (contains == true)
                {
                    EditorGUILayout.HelpBox("Namespace already exists.", MessageType.Error);
                    hasErrors = true;
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Assembly was not found. Try to re-open Unity.", MessageType.Error);
                hasErrors = true;
            }

            var pattern = @"^([A-Za-z]+[\.a-zA-Z0-9_]*)$";
            var ns      = this.projectNamespace;
            var rgx     = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var isMatch = rgx.IsMatch(ns);

            if (isMatch == false)
            {
                EditorGUILayout.HelpBox("Namespace can contains `.`, `_`, A-Z and 0-9. First symbol must be a char.", MessageType.Error);
                hasErrors = true;
            }

            GUILayout.FlexibleSpace();

            CustomGUI.Splitter();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Cancel", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(40f)) == true)
                {
                    this.state = State.ProjectSelector;
                }

                GUILayout.FlexibleSpace();

                oldState    = GUI.enabled;
                GUI.enabled = oldState && !hasErrors;
                if (GUILayout.Button("Create & Open", FlowSystemEditorWindow.defaultSkin.button, GUILayout.Width(150f), GUILayout.Height(40f)) == true)
                {
                    this.state = State.ProjectSelector;
                    var data = this.CreateProject(this.projectFolder, this.projectNamespace);
                    this.editor.OpenFlowData(data);

                    EditorUtilities.ResetCache <FlowData>();
                }
                GUI.enabled = oldState;
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 14
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();


            cont = new GUIContent("Energy Capacity:", "The maximum amount of energy available to player. Energy is used to cast ability and is recharged overtime");
            instance.fullEnergy = EditorGUILayout.FloatField(cont, instance.fullEnergy);

            cont = new GUIContent("Energy Rate:", "The amount of energy to be recharged at each second");
            instance.energyRate = EditorGUILayout.FloatField(cont, instance.energyRate);

            cont = new GUIContent("Full Energy Start:", "Check to start the game with full energy");
            instance.startWithFullEnergy = EditorGUILayout.Toggle(cont, instance.startWithFullEnergy);

            if (!instance.startWithFullEnergy)
            {
                cont            = new GUIContent(" - Starting Energy:", "The amount of energy player possess at the start of the game");
                instance.energy = EditorGUILayout.FloatField(cont, instance.energy);
            }

            cont = new GUIContent("Charge Before Spawn:", "Check to start energy charging before spawning");
            instance.onlyChargeOnSpawn = EditorGUILayout.Toggle(cont, instance.onlyChargeOnSpawn);

            EditorGUILayout.Space();

            cont = new GUIContent("Default Indicator:", "The default cursor indicator to used for ability target selecting in case the selected ability doesnt have a designated indicator");
            instance.defaultIndicator = (Transform)EditorGUILayout.ObjectField(cont, instance.defaultIndicator, typeof(Transform), true);


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showAbilityList = EditorGUILayout.Foldout(showAbilityList, "Show Ability List");
            EditorGUILayout.EndHorizontal();
            if (showAbilityList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < abilityList.Count; i++)
                    {
                        instance.unavailableIDList.Add(abilityList[i].ID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < abilityList.Count; i++)
                {
                    Ability ability = abilityList[i];

                    if (ability.disableInAbilityManager)
                    {
                        if (!instance.unavailableIDList.Contains(ability.ID))
                        {
                            instance.unavailableIDList.Add(ability.ID);
                        }
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, ability.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(ability.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    bool flag = !instance.unavailableIDList.Contains(ability.ID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                                           //switch it around in runtime
                    }
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the ability in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableIDList.Remove(ability.ID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(ability.ID))
                            {
                                instance.unavailableIDList.Add(ability.ID);
                            }
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();


            if (GUILayout.Button("Open AbilityEditor"))
            {
                AbilityEditorWindow.Init();
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemplo n.º 15
0
        public override void OnInspectorGUI()
        {
            infoBoxStyle = EditorStyles.helpBox;
            //infoBoxStyle.border = new RectOffset(10, 10, 10, 10);
            Texture2D texture = new Texture2D(1, 1);

            texture.SetPixels(new Color[] { new Color(0.3f, 0.3f, 0.3f) });
            texture.Apply();
            infoBoxStyle.normal.background = texture;
            infoBoxStyle.richText          = true;
            infoBoxStyle.wordWrap          = true;
            infoBoxStyle.fontSize          = 12;
            infoBoxStyle.padding           = new RectOffset(20, 20, 5, 5);
            infoBoxStyle.alignment         = TextAnchor.MiddleLeft;

            serializedObject.Update();

            Texture2D whiteTexture = Texture2D.whiteTexture;
            GUIStyle  style        = new GUIStyle("box")
            {
                margin = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0)
            };

            style.normal.background = whiteTexture;

            Color defaultColor = GUI.backgroundColor;

            GUI.backgroundColor = EditorUtilities.L1;
            GUILayout.BeginVertical(style, GUILayout.Height(Screen.height - 155f));
            GUI.backgroundColor = defaultColor;

            Color sectionColor = EditorUtilities.L2;


            base.OnInspectorGUI();

            string completeTypeString = ((WorldObjectType.CompleteType)serializedObject.FindProperty("completeType").enumValueIndex).ToString();
            string rightInfo          = completeTypeString;

            showcompleteInfo = EditorUtilities.BeginInspectorSection("Complete", completeIcon, showcompleteInfo, sectionColor, sectionBackground, rightInfo);
            if (showcompleteInfo)
            {
                // TODO: On Change make sure addItems timing is Created
                EditorGUI.BeginChangeCheck();
                SerializedProperty serializedBuildType = serializedObject.FindProperty("completeType");
                EditorGUILayout.PropertyField(serializedBuildType);
                if (EditorGUI.EndChangeCheck() && serializedBuildType.enumValueIndex == (int)WorldObjectType.CompleteType.None)
                {
                    serializedObject.FindProperty("addDefaultInventoryTiming").enumValueIndex = (int)WorldObjectType.AddInventoryTiming.Created;
                }

                if (serializedBuildType.enumValueIndex == (int)WorldObjectType.CompleteType.Built)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("itemsConsumedPerBuild"));
                }
                else if (serializedBuildType.enumValueIndex == (int)WorldObjectType.CompleteType.Grows)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("growthRate"));
                }

                if (serializedBuildType.enumValueIndex != (int)WorldObjectType.CompleteType.None)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("pointsToComplete"));

                    if (serializedObject.FindProperty("skinPrefabMappings").arraySize == 0)
                    {
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("autoScale"));
                    }
                }
            }
            EditorUtilities.EndInspectorSection(showcompleteInfo);

            rightInfo      = serializedObject.FindProperty("canBeDamaged").boolValue ? "Allowed" : "None";
            showdamageInfo = EditorUtilities.BeginInspectorSection("Damage", damageIcon, showdamageInfo, sectionColor, sectionBackground, rightInfo);
            if (showdamageInfo)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("canBeDamaged"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("damageToDestroy"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("removeOnFullDamage"));
            }
            EditorUtilities.EndInspectorSection(showdamageInfo);

            rightInfo = "";
            int numStates = serializedObject.FindProperty("states").arraySize;

            for (int i = 0; i < numStates; i++)
            {
                if (serializedObject.FindProperty("states").GetArrayElementAtIndex(i).FindPropertyRelative("name") != null)
                {
                    rightInfo += serializedObject.FindProperty("states").GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue + ", ";
                }
            }
            rightInfo = rightInfo.Length == 0 ? "None" : rightInfo.Substring(0, rightInfo.Length - 2);

            showStates = EditorUtilities.BeginInspectorSection("States", statesIcon, showStates, sectionColor, sectionBackground, rightInfo);
            if (showStates)
            {
                stateList.DoLayoutList();

                bool anyOutputChanges     = false;
                SerializedProperty states = serializedObject.FindProperty("states");
                for (int i = 0; i < states.arraySize; i++)
                {
                    SerializedProperty state = states.GetArrayElementAtIndex(i);
                    if (state.FindPropertyRelative("hasEnterOutputChanges").boolValue || state.FindPropertyRelative("hasExitOutputChanges").boolValue)
                    {
                        anyOutputChanges = true;
                        break;
                    }
                }

                if (anyOutputChanges)
                {
                    outputChangeList.DoLayoutList();
                }
            }
            EditorUtilities.EndInspectorSection(showStates);

            int numSkinPrefabs = serializedObject.FindProperty("skinPrefabMappings").arraySize;

            rightInfo       = numSkinPrefabs > 0 ? numSkinPrefabs.ToString() : "None";
            showSkinPrefabs = EditorUtilities.BeginInspectorSection("Skin Prefabs", skinPrefabsIcon, showSkinPrefabs, sectionColor,
                                                                    sectionBackground, rightInfo);
            if (showSkinPrefabs)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("skinGameObjectName"));
                GUILayout.Space(10);
                prefabList.DoLayoutList();
            }
            EditorUtilities.EndInspectorSection(showSkinPrefabs);

            int numRecipes = serializedObject.FindProperty("recipes").arraySize;

            rightInfo   = numRecipes > 0 ? numRecipes.ToString() : "None";
            showRecipes = EditorUtilities.BeginInspectorSection("Recipes", recipesIcon, showRecipes, sectionColor, sectionBackground, rightInfo);
            if (showRecipes)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("recipes"));
            }
            EditorUtilities.EndInspectorSection(showRecipes);

            GUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
Exemplo n.º 16
0
 public void ExecuteInsertBlockQuote(object sender, ExecutedRoutedEventArgs e) => IfNotReadOnly(() => EditorUtilities.InsertBlockQuote(EditBox));
Exemplo n.º 17
0
        private float InputConditionHeight(int index)
        {
            SerializedProperty element = inputConditionList.serializedProperty.GetArrayElementAtIndex(index);

            return(EditorUtilities.InputConditionHeight(mappingType, element, index, infoBoxStyle));
        }
Exemplo n.º 18
0
 public void ExecuteInsertHyperlink(object sender, ExecutedRoutedEventArgs e) => IfNotReadOnly(() => EditorUtilities.InsertHyperlink(EditBox, e.Parameter as string));
Exemplo n.º 19
0
        private float OutputChangeHeight(int index)
        {
            SerializedProperty element = outputChangeList.serializedProperty.GetArrayElementAtIndex(index);

            return(EditorUtilities.OutputChangeHeight(index, mappingType, element, infoBoxStyle));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 获取默认的导出根路径
        /// </summary>
        public static string GetDefaultOutputRootPath()
        {
            string projectPath = EditorUtilities.GetProjectPath();

            return($"{projectPath}/Assets/StreamingAssets");
        }
Exemplo n.º 21
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            cont = new GUIContent("Persistant Progress", "Check to use persistantProgress\nThe progress done in this level will be carried to next\nEnable this will cause all the level to use the perk enabled in this instance, perk enabled/disable in subsequent PerkManager instance will be ignored");
            instance.persistantProgress = EditorGUILayout.Toggle(cont, instance.persistantProgress);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showPerkList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.purchasedIDList = new List <int>();

                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < perkList.Count; i++)
                    {
                        instance.unavailableIDList.Add(perkList[i].ID);
                    }
                }
                EditorGUILayout.EndHorizontal();


                for (int i = 0; i < perkList.Count; i++)
                {
                    Perk perk = perkList[i];


                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, perk.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();
                    bool flag = !instance.unavailableIDList.Contains(perk.ID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                                           //switch it around in runtime
                    }
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableIDList.Remove(perk.ID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(perk.ID))
                            {
                                instance.unavailableIDList.Add(perk.ID);
                                instance.purchasedIDList.Remove(perk.ID);
                            }
                        }
                    }

                    if (!instance.unavailableIDList.Contains(perk.ID))
                    {
                        flag = instance.purchasedIDList.Contains(perk.ID);
                        EditorGUILayout.LabelField(new GUIContent("- purchased:", "Check to set the perk as purchased right from the start"), GUILayout.Width(75));
                        flag = EditorGUILayout.Toggle(flag);
                        if (!flag)
                        {
                            instance.purchasedIDList.Remove(perk.ID);
                        }
                        else if (!instance.purchasedIDList.Contains(perk.ID))
                        {
                            instance.purchasedIDList.Add(perk.ID);
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Open PerkEditor"))
            {
                PerkEditorWindow.Init();
            }
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 清空流文件夹
        /// </summary>
        public static void ClearStreamingAssetsFolder()
        {
            string streamingPath = Application.dataPath + "/StreamingAssets";

            EditorUtilities.ClearFolder(streamingPath);
        }
Exemplo n.º 23
0
 private IEnumerable GetAllAsteroidID()
 {
     return(EditorUtilities.GetAllAssets <AsteroidData>().Select(x => x.name));
 }
Exemplo n.º 24
0
        public static Vector3 DrawStat(UnitStat stat, float startX, float startY, float statContentHeight, UnitTower tower, UnitCreep creep)
        {
            List <Rsc> rscList = EditorDBManager.GetRscList();

            float width  = 150;
            float fWidth = 35;
            float spaceX = 130;
            float height = 18;
            float spaceY = height + 2;

            //startY-=spaceY;

            GUI.Box(new Rect(startX, startY, 220, statContentHeight - startY), "");

            startX += 10;     startY += 10;

            if (tower != null)
            {
                cont = new GUIContent("Construct Duration:", "The time in second it takes to construct (if this is the first level)/upgrade (if this is not the first level)");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.buildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buildDuration);

                cont = new GUIContent("Deconstruct Duration:", "The time in second it takes to deconstruct if the unit is in this level");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.unBuildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.unBuildDuration);


                if (stat.cost.Count != rscList.Count)
                {
                    while (stat.cost.Count > rscList.Count)
                    {
                        stat.cost.RemoveAt(stat.cost.Count - 1);
                    }
                    while (stat.cost.Count < rscList.Count)
                    {
                        stat.cost.Add(0);
                    }
                }
                cont = new GUIContent("Build/Upgrade Cost:", "The resource required to build/upgrade to this level");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                int count = 0;    startY += spaceY;         float cachedX = startX;
                for (int i = 0; i < rscList.Count; i++)
                {
                    EditorUtilities.DrawSprite(new Rect(startX + 10, startY - 1, 20, 20), rscList[i].icon);
                    stat.cost[i] = EditorGUI.IntField(new Rect(startX + 30, startY, fWidth, height), stat.cost[i]);
                    count       += 1;       startX += 65;
                    if (count == 3)
                    {
                        startY += spaceY; startX = cachedX;
                    }
                }
                startX = cachedX; startY += 5;

                startY += spaceY + 5;
            }



            if ((tower && TowerUseShootObject(tower)) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.shootObject = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 4 * fWidth - 20, height), stat.shootObject, typeof(ShootObject), false);
                startY          += 5;
            }

            if (tower && TowerUseShootObjectT(tower))
            {
                cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.shootObjectT = (Transform)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 4 * fWidth - 20, height), stat.shootObjectT, typeof(Transform), false);
                startY           += 5;
            }

            if ((tower && TowerDealDamage(tower)) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("Damage(Min/Max):", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.damageMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.damageMin);
                stat.damageMax = EditorGUI.FloatField(new Rect(startX + spaceX + fWidth, startY, fWidth, height), stat.damageMax);

                cont = new GUIContent("Cooldown:", "Duration between each attack");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.cooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.cooldown);


                cont = new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.range = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.range);

                //~ cont=new GUIContent("Range(Min/Max):", "");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ stat.minRange=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.minRange);
                //~ stat.range=EditorGUI.FloatField(new Rect(startX+spaceX+fWidth, startY, fWidth, height), stat.range);

                cont = new GUIContent("AOE Radius:", "Area-of-Effective radius. When the shootObject hits it's target, any other hostile unit within the area from the impact position will suffer the same target as the target.\nSet value to >0 to enable. ");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.aoeRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.aoeRadius);



                cont = new GUIContent("Hit Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's dodgeChance. Assume two targets with 0 dodgeChance and .2 dodgeChance and the hitChance set to 1, the unit will always hits the target and have 20% chance to miss the second target.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.hit = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.hit);

                if (!creep)
                {
                    cont = new GUIContent("Dodge Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's hitChance. Assume two attackers with 1 hitChance and .8 hitChance and the dodgeChance set to .2, the chances to dodge attack from each attacker are 20% and 40% respectively.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    stat.dodge = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dodge);
                }


                cont = new GUIContent("Stun", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= spaceY;

                cont = new GUIContent("        - Chance:", "Chance to stun the target in each successful attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.stun.chance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.stun.chance);

                cont = new GUIContent("        - Duration:", "The stun duration in second");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.stun.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.stun.duration);



                cont = new GUIContent("Critical", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= spaceY;

                cont = new GUIContent("            - Chance:", "Chance to score critical hit in attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.crit.chance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.crit.chance);

                cont = new GUIContent("            - Multiplier:", "Damage multiplier for successful critical hit. Takes value from 0 and above with with 0.5 being 50% of normal damage as bonus");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.crit.dmgMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.crit.dmgMultiplier);



                cont = new GUIContent("Slow", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= spaceY;

                cont = new GUIContent("         - Duration:", "The effect duration in second");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.slow.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.slow.duration);

                cont = new GUIContent("         - Multiplier:", "Move speed multiplier. Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.slow.slowMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.slow.slowMultiplier);



                cont = new GUIContent("Dot", "Damage over time");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= spaceY;

                cont = new GUIContent("        - Duration:", "The effect duration in second");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.dot.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dot.duration);

                cont = new GUIContent("        - Interval:", "Duration between each tick. Damage is applied at each tick.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.dot.interval = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dot.interval);

                cont = new GUIContent("        - Damage:", "Damage applied at each tick");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.dot.value = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dot.value);



                cont = new GUIContent("InstantKill", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= spaceY;

                cont = new GUIContent("                - Chance:", "The chance to instant kill the target. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.instantKill.chance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.instantKill.chance);

                cont = new GUIContent("        - HP Threshold:", "The HP threshold of the target in order for the instantKill to become valid. Take value from 0-1 with 0.3 being 30% of the fullHP.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.instantKill.HPThreshold = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.instantKill.HPThreshold);


                cont = new GUIContent("Damage Shield Only:", "When checked, unit will only inflict shield damage");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.damageShieldOnly = EditorGUI.Toggle(new Rect(startX + spaceX, startY, fWidth, height), stat.damageShieldOnly);

                cont = new GUIContent("Shield Break:", "The chance of the unit's attack to damage target's shield and disable shield regen permenantly\nTakes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.shieldBreak = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.shieldBreak);

                cont = new GUIContent("Shield Pierce:", "The chance of the unit's attack to bypass target's shield and damage HP directly\nTakes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.shieldPierce = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.shieldPierce);
            }



            if ((tower && tower.type == _TowerType.Support) || (creep && creep.type == _CreepType.Support))
            {
                cont = new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.range = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.range);
                startY    += 5;

                cont = new GUIContent("Buff:", "Note: Buffs from multple tower doesnt stack, however when there's difference in the buff strength, the stronger buff applies. A tower can gain maximum dmage buff from one source and maximum range buff from another");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);    startY -= spaceY;

                cont = new GUIContent("        - Damage:", "Damage buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in damage");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.damageBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.damageBuff);

                cont = new GUIContent("        - Cooldown:", "Dooldown buff multiplier. Takes value from 0-1 with 0.2 being reduce cooldown by 20%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.cooldownBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.cooldownBuff);

                cont = new GUIContent("        - Range:", "Range buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in range");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.rangeBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.rangeBuff);

                cont = new GUIContent("        - Critical:", "Critical hit chance buff modifier. Takes value from 0 and above with 0.25 being 25% increase in critical hit chance");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.criticalBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.criticalBuff);

                cont = new GUIContent("        - Hit:", "Hit chance buff modifier. Takes value from 0 and above with .2 being 20% increase in hit chance");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.hitBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.hitBuff);

                cont = new GUIContent("        - Dodge:", "Dodge chance buff modifier. Takes value from 0 and above with 0.15 being 15% increase in dodge chance");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.dodgeBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.dodgeBuff);

                cont = new GUIContent("        - HP Regen:", "HP Regeneration Buff. Takes value from 0 and above with 2 being gain 2HP second ");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.regenHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.regenHP);
            }


            if (tower && tower.type == _TowerType.Resource)
            {
                if (stat.rscGain.Count != rscList.Count)
                {
                    while (stat.rscGain.Count > rscList.Count)
                    {
                        stat.rscGain.RemoveAt(stat.rscGain.Count - 1);
                    }
                    while (stat.rscGain.Count < rscList.Count)
                    {
                        stat.rscGain.Add(0);
                    }
                }
                cont = new GUIContent("Resource Gain:", "The resource gain by unit at each cooldown interval\nOnly applicable to ResourceTower");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                int count = 0;    startY += spaceY;         float cachedX = startX;
                for (int i = 0; i < rscList.Count; i++)
                {
                    EditorUtilities.DrawSprite(new Rect(startX + 10, startY - 1, 20, 20), rscList[i].icon);
                    stat.rscGain[i] = EditorGUI.IntField(new Rect(startX + 30, startY, fWidth, height), stat.rscGain[i]);
                    count          += 1;       startX += 65;
                    if (count == 3)
                    {
                        startY += spaceY; startX = cachedX;
                    }
                }
                startX = cachedX; startY += 5;
            }


            if (tower)
            {
                startY += 10;
                cont    = new GUIContent("Custom Description:", "Check to use use custom description. If not, the default one (generated based on the effect) will be used");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.useCustomDesp = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), stat.useCustomDesp);
                if (stat.useCustomDesp)
                {
                    GUIStyle style = new GUIStyle("TextArea");
                    style.wordWrap = true;
                    stat.desp      = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 200, 90), stat.desp, style);
                    startY        += 90;
                }
            }



            statContentHeight = startY + spaceY + 5;

            return(new Vector3(startX + 220, startY, statContentHeight));
        }
Exemplo n.º 25
0
    public override void OnInspectorGUI()
    {
        _listOfClips     = EditorUtilities.GetListOfAudioClips();
        _listOFParticles = EditorUtilities.GetListOfParticles();

        var melee = target as MeleeAttack;

        if (melee.isAbility)
        {
            EditorGUILayout.HelpBox("This is the BATTLE AXE", MessageType.Info, true);
        }


        DrawDefaultInspector();

        _choice[0] = EditorUtilities.GetSelectedClip(_listOfClips, melee.PlayerImpact);
        _choice[1] = EditorUtilities.GetSelectedClip(_listOfClips, melee.Swipe);
        _choice[2] = EditorUtilities.GetSelectedClip(_listOfClips, melee.Sheath);
        _choice[3] = EditorUtilities.GetSelectedClip(_listOfClips, melee.Clash);
        _choice[4] = EditorUtilities.GetSelectedClip(_listOfClips, melee.ClashCrowd);
        _choice[5] = EditorUtilities.GetSelectedClip(_listOfClips, melee.ClashAftermath);

        if (melee.Trail == null)
        {
            _particle[0] = 0;
        }
        else
        {
            _particle[0] = EditorUtilities.GetSelectedParticle(melee.Trail);
        }

        if (melee.Clash == null)
        {
            _particle[1] = 0;
        }
        else
        {
            _particle[1] = EditorUtilities.GetSelectedParticle(melee.ClashingParticle);
        }

        if (melee.CrowdParticle == null)
        {
            _particle[2] = 0;
        }
        else
        {
            _particle[2] = EditorUtilities.GetSelectedParticle(melee.CrowdParticle);
        }


        _choice[0] = EditorGUILayout.Popup("Player Impact SFX", _choice[0], _listOfClips);
        _choice[1] = EditorGUILayout.Popup("Swipe SFX", _choice[1], _listOfClips);
        _choice[2] = EditorGUILayout.Popup("Sheath SFX", _choice[2], _listOfClips);
        _choice[3] = EditorGUILayout.Popup("Clash SFX", _choice[3], _listOfClips);
        _choice[4] = EditorGUILayout.Popup("Clash Crowd SFX", _choice[4], _listOfClips);
        _choice[5] = EditorGUILayout.Popup("Clash Aftermath SFX", _choice[5], _listOfClips);


        if (melee.isAbility)
        {
            _choice[6] = EditorUtilities.GetSelectedClip(_listOfClips, melee.AbilitySecondSound);
            _choice[7] = EditorUtilities.GetSelectedClip(_listOfClips, melee.AbilityAerial);

            _choice[6] = EditorGUILayout.Popup("Ability Secondary SFX", _choice[6], _listOfClips);
            _choice[7] = EditorGUILayout.Popup("Ability Aerial SFX", _choice[7], _listOfClips);

            melee.AbilitySecondSound = _listOfClips[_choice[6]];
            melee.AbilityAerial      = _listOfClips[_choice[7]];
        }

        _particle[0] = EditorGUILayout.Popup("Melee Trail FX", _particle[0], _listOFParticles);
        _particle[1] = EditorGUILayout.Popup("Clash FX", _particle[1], _listOFParticles);
        _particle[2] = EditorGUILayout.Popup("Crowd on Clash FX", _particle[2], _listOFParticles);

        melee.PlayerImpact   = _listOfClips[_choice[0]];
        melee.Swipe          = _listOfClips[_choice[1]];
        melee.Sheath         = _listOfClips[_choice[2]];
        melee.Clash          = _listOfClips[_choice[3]];
        melee.ClashCrowd     = _listOfClips[_choice[4]];
        melee.ClashAftermath = _listOfClips[_choice[5]];

        melee.Trail            = Database.instance.Particles[_particle[0]];
        melee.ClashingParticle = Database.instance.Particles[_particle[1]];
        melee.CrowdParticle    = Database.instance.Particles[_particle[2]];

        EditorUtility.SetDirty(target);
    }
Exemplo n.º 26
0
        public static Vector3 DrawIconAndName(Unit unit, float startX, float startY)
        {
            float cachedX = startX;
            float cachedY = startY;

            EditorUtilities.DrawSprite(new Rect(startX, startY, 60, 60), unit.iconSprite);
            startX += 65;

            cont = new GUIContent("Name:", "The unit name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), unit.unitName);

            cont = new GUIContent("Icon:", "The unit icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.iconSprite = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), unit.iconSprite, typeof(Sprite), false);

            startX -= 65;
            startY  = cachedY;
            startX += 35 + spaceX + width;              //startY+=20;
            cont    = new GUIContent("HitPoint(HP):", "The unit default's HitPoint.\nThis is the base value to be modified by various in game bonus.");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            unit.defaultHP = EditorGUI.FloatField(new Rect(startX + 80, startY, 40, height), unit.defaultHP);

            cont = new GUIContent(" - Regen:", "HP regeneration rate. The amount of HP to be regenerated per second");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.HPRegenRate = EditorGUI.FloatField(new Rect(startX + 80, startY, 40, height), unit.HPRegenRate);

            if (unit.HPRegenRate <= 0)
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1);
            }
            cont = new GUIContent(" - Stagger:", "HP regeneration stagger duration(in second). The duration which the HP regen will be stopped when a unit is hit. Once the duration is passed the HP will start regenerating again");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.HPStaggerDuration = EditorGUI.FloatField(new Rect(startX + 80, startY, 40, height), unit.HPStaggerDuration);
            GUI.color = Color.white;

            startY = cachedY;         startX += 145;
            cont   = new GUIContent("Shield:", "The unit default's Shield. Shield can act as a regenerative damage absorber. A unit only be damaged once its shield has been depleted.\nThis is the base value to be modified by various in game bonus.");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            unit.defaultShield = EditorGUI.FloatField(new Rect(startX + 70, startY, 40, height), unit.defaultShield);

            if (unit.defaultShield <= 0)
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1);
            }
            cont = new GUIContent(" - Regen:", "Shield regeneration rate. The amount of shield to be regenerated per second");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.shieldRegenRate = EditorGUI.FloatField(new Rect(startX + 70, startY, 40, height), unit.shieldRegenRate);
            GUI.color            = Color.white;

            if (unit.defaultShield <= 0 || unit.shieldRegenRate <= 0)
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1);
            }
            cont = new GUIContent(" - Stagger:", "Shield regeneration stagger duration(in second). The duration which the shield regen will be stopped when a unit is hit. Once the duration is passed the shield will start regenerating again");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.shieldStaggerDuration = EditorGUI.FloatField(new Rect(startX + 70, startY, 40, height), unit.shieldStaggerDuration);

            GUI.color = Color.white;


            float contentWidth = startX - cachedX + spaceX + 25;

            //GUI.Box(new Rect(cachedX, cachedY, contentWidth, startY-cachedY+spaceY), "");

            return(new Vector3(startX, startY + spaceY, contentWidth));
        }
Exemplo n.º 27
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_FPController, new UnityEngine.GUIContent("First Person Character"));
            EditorGUILayout.PropertyField(m_HealthController);

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_TargetTransform);

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_OverallSpeed);
            EditorGUILayout.PropertyField(m_WalkingMotionData);
            EditorGUILayout.PropertyField(m_BrokenLegsMotionData);
            EditorGUILayout.PropertyField(m_RunningMotionData);

            EditorGUILayout.Space();

            EditorUtilities.LerpAnimationDrawer("Brace For Jump Animation", m_BraceForJumpAnimation, true, m_Target.transform);

            EditorUtilities.LerpAnimationDrawer("Jump Animation", m_JumpAnimation, true, m_Target.transform);

            EditorUtilities.LerpAnimationDrawer("Landing Animation", m_LandingAnimation, true, m_Target.transform);

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Breath Animation", m_BreathAnimation);

            if (m_BreathAnimation.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_BreathAnimation.boolValue))
                {
                    EditorGUILayout.PropertyField(m_BreathAnimationMode);
                    EditorGUILayout.PropertyField(m_BreathingSpeed);
                    EditorGUILayout.PropertyField(m_BreathingAmplitude);

                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(m_HoldBreath, new UnityEngine.GUIContent("Hold Breath Sound"));
                    EditorGUILayout.PropertyField(m_Exhale, new UnityEngine.GUIContent("Exhale Sound"));
                    EditorGUILayout.PropertyField(m_HoldBreathVolume);
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.ToggleHeader("Lean Animation", m_Lean);

            if (m_Lean.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                using (new EditorGUI.DisabledScope(!m_Lean.boolValue))
                {
                    EditorGUILayout.PropertyField(m_LeanAmount);
                    EditorGUILayout.PropertyField(m_LeanAngle);
                    EditorGUILayout.PropertyField(m_LeanSpeed);
                }
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.FoldoutHeader("Hit Animation", m_MinHitRotation);

            if (m_MinHitRotation.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(m_MinHitRotation);
                EditorGUILayout.PropertyField(m_MaxHitRotation);

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(m_HitDuration);
            }

            EditorGUI.indentLevel = 0;
            EditorUtilities.LerpAnimationDrawer("Vault Animation", m_VaultAnimation);

            EditorGUI.indentLevel = 0;
            EditorUtilities.FoldoutHeader("Explosion Animation", m_ExplosionShake);

            if (m_ExplosionShake.isExpanded)
            {
                EditorGUI.indentLevel = 1;
                ShakePropertiesDrawer(m_ExplosionShake);
            }

            EditorUtilities.DrawSplitter();

            EditorGUI.indentLevel = 0;
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 28
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            cont = new GUIContent("Grid Size:", "The grid size of the grid on the platform");
            instance.gridSize = EditorGUILayout.FloatField(cont, instance.gridSize);

            cont = new GUIContent("AutoSearchForPlatform:", "Check to let the BuildManager automatically serach of all the build platform in game\nThis will override the BuildPlatform list");
            instance.autoSearchForPlatform = EditorGUILayout.Toggle(cont, instance.autoSearchForPlatform);

            cont = new GUIContent("AutoAdjustTextureToGrid:", "Check to let the BuildManager reformat the texture tiling of the platform to fix the gridsize");
            instance.AutoAdjustTextureToGrid = EditorGUILayout.Toggle(cont, instance.AutoAdjustTextureToGrid);

            EditorGUILayout.Space();

            if (GUILayout.Button("Enable All Towers On All Platforms") && !Application.isPlaying)
            {
                EnableAllToweronAllPlatform();
            }

            cont = new GUIContent("Build Platforms", "Build Platform in this level\nOnly applicable when AutoSearchForPlatform is unchecked");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPlatforms = EditorGUILayout.Foldout(showPlatforms, cont);
            EditorGUILayout.EndHorizontal();

            if (showPlatforms)
            {
                cont = new GUIContent("Build Platforms:", "The grid size of the grid on the platform");
                float listSize = instance.buildPlatforms.Count;
                listSize = EditorGUILayout.FloatField("    Size:", listSize);

                //if(!EditorGUIUtility.editingTextField && listSize!=instance.buildPlatforms.Count){
                if (listSize != instance.buildPlatforms.Count)
                {
                    while (instance.buildPlatforms.Count < listSize)
                    {
                        instance.buildPlatforms.Add(null);
                    }
                    while (instance.buildPlatforms.Count > listSize)
                    {
                        instance.buildPlatforms.RemoveAt(instance.buildPlatforms.Count - 1);
                    }
                }

                for (int i = 0; i < instance.buildPlatforms.Count; i++)
                {
                    instance.buildPlatforms[i] = (PlatformTD)EditorGUILayout.ObjectField("    Element " + i, instance.buildPlatforms[i], typeof(PlatformTD), true);
                }
            }



            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showTowerList = EditorGUILayout.Foldout(showTowerList, "Show Tower List");
            EditorGUILayout.EndHorizontal();
            if (showTowerList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableTowerIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableTowerIDList = new List <int>();
                    for (int i = 0; i < towerList.Count; i++)
                    {
                        instance.unavailableTowerIDList.Add(towerList[i].prefabID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                //scrollPosition = GUILayout.BeginScrollView (scrollPosition);

                for (int i = 0; i < towerList.Count; i++)
                {
                    UnitTower tower = towerList[i];

                    if (tower.disableInBuildManager)
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, tower.iconSprite, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(tower.unitName, GUILayout.ExpandWidth(false));

                    bool flag = !instance.unavailableTowerIDList.Contains(tower.prefabID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                           //switch it around in runtime
                    }
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the tower in this level"), flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableTowerIDList.Remove(tower.prefabID);
                        }
                        else
                        {
                            if (!instance.unavailableTowerIDList.Contains(tower.prefabID))
                            {
                                instance.unavailableTowerIDList.Add(tower.prefabID);
                            }
                        }
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }

                //GUILayout.EndScrollView ();
            }

            EditorGUILayout.Space();

            int cursorMode = (int)instance.cursorIndicatorMode;

            cont     = new GUIContent("Tile Cursor Mode:", "The way to indicate a tile on a grid when it's currently being hovered on by the cursor");
            contList = new GUIContent[cursorIndModeLabel.Length];
            for (int i = 0; i < contList.Length; i++)
            {
                contList[i] = new GUIContent(cursorIndModeLabel[i], cursorIndModeTooltip[i]);
            }
            cursorMode = EditorGUILayout.Popup(cont, cursorMode, contList);
            instance.cursorIndicatorMode = (BuildManager._CursorIndicatorMode)cursorMode;

            EditorGUILayout.Space();



            if (GUILayout.Button("Open TowerEditor"))
            {
                UnitTowerEditorWindow.Init();
            }
            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemplo n.º 29
0
        void DrawProfileInspectorGUI()
        {
            EditorGUILayout.Space();

            bool assetHasChanged = false;
            bool showCopy        = m_Profile.objectReferenceValue != null;

            // The layout system sort of break alignement when mixing inspector fields with custom
            // layouted fields, do the layout manually instead
            int   buttonWidth    = showCopy ? 45 : 60;
            float indentOffset   = EditorGUI.indentLevel * 15f;
            var   lineRect       = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
            var   labelRect      = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height);
            var   fieldRect      = new Rect(labelRect.xMax, lineRect.y, lineRect.width - labelRect.width - buttonWidth * (showCopy ? 2 : 1), lineRect.height);
            var   buttonNewRect  = new Rect(fieldRect.xMax, lineRect.y, buttonWidth, lineRect.height);
            var   buttonCopyRect = new Rect(buttonNewRect.xMax, lineRect.y, buttonWidth, lineRect.height);

            EditorGUI.PrefixLabel(labelRect, m_ProfileLabel);

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                m_Profile.objectReferenceValue
                    = (PostProcessProfile)EditorGUI.ObjectField(
                          fieldRect, m_Profile.objectReferenceValue, typeof(PostProcessProfile), false);
                assetHasChanged = scope.changed;
            }

            if (GUI.Button(
                    buttonNewRect,
                    EditorUtilities.GetContent("New|Create a new profile."),
                    showCopy ? EditorStyles.miniButtonLeft : EditorStyles.miniButton))
            {
                // By default, try to put assets in a folder next to the currently active
                // scene file. If the user isn't a scene, put them in root instead.
                var targetName = Target.name;
                var scene      = Target.gameObject.scene;
                var asset      = CreatePostProcessProfile(scene, targetName);
                m_Profile.objectReferenceValue = asset;
                assetHasChanged = true;
            }

            if (showCopy && GUI.Button(
                    buttonCopyRect,
                    EditorUtilities.GetContent("Clone|Create a new profile and copy the content of the currently assigned profile."),
                    EditorStyles.miniButtonRight))
            {
                // Duplicate the currently assigned profile and save it as a new profile
                var origin = (PostProcessProfile)m_Profile.objectReferenceValue;
                var path   = AssetDatabase.GetAssetPath(origin);
                path = AssetDatabase.GenerateUniqueAssetPath(path);

                var asset = Instantiate(origin);
                asset.settings.Clear();
                AssetDatabase.CreateAsset(asset, path);

                foreach (var item in origin.settings)
                {
                    var itemCopy = Instantiate(item);
                    itemCopy.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
                    itemCopy.name      = item.name;
                    asset.settings.Add(itemCopy);
                    AssetDatabase.AddObjectToAsset(itemCopy, asset);
                }

                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                m_Profile.objectReferenceValue = asset;
                assetHasChanged = true;
            }

            if (m_Profile.objectReferenceValue == null)
            {
                if (assetHasChanged && m_EffectList != null)
                {
                    m_EffectList.Clear(); // Asset wasn't null before, do some cleanup
                }
                EditorGUILayout.HelpBox(
                    "Assign an existing Post-process Profile by choosing an asset, or create a new one by "
                    + "clicking the \"New\" button.\nNew assets are automatically put in a folder next "
                    + "to your scene file. If your scene hasn't been saved yet they will be created "
                    + "at the root of the Assets folder.",
                    MessageType.Info);
            }
            else
            {
                if (assetHasChanged)
                {
                    RefreshEffectListEditor((PostProcessProfile)m_Profile.objectReferenceValue);
                }
                if (m_EffectList != null)
                {
                    m_EffectList.OnGUI();
                }
            }
        }
 public void Init(string label)
 {
     EditorUtilities.StringToBendSettings(label, out shaderSupportedBendTypes, out shaderSupportedBendIDs, out hasNormalTransform);
 }