private void OnGUI() { EditorStaticMethods.ShowFolderAndAskIfCreateNew(ref selectedFolderRef, ref createFolder); GUILayout.Space(12); float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth *= 1.5f; ShowWeaponSetCreationParameters(selectedFolderRef, ref newWeaponName, createFolder, ref createLinkedObject, ref newWeaponCreationParameters); EditorGUIUtility.labelWidth = oldWidth; if (selectedFolderRef != null) { if (GUILayout.Button("Create the new Weapon : \"" + newWeaponName + "\" !")) { string finalFolderPath = selectedFolderRef.GetFolderPath(); if (createFolder) { string folderCreationPath = finalFolderPath; finalFolderPath = AssetDatabase.GenerateUniqueAssetPath(finalFolderPath + "/" + newWeaponName + " Set"); Debug.Log("Create Folder \"" + newWeaponName + "Set" + "\" in \"" + folderCreationPath + "\""); AssetDatabase.CreateFolder(folderCreationPath, newWeaponName + " Set"); } WeaponScript newWeaponPrefab = null; if (createLinkedObject) { WeaponScript newWeapon = WeaponCreationParameters.ComposeWeapon(newWeaponCreationParameters, newWeaponName); newWeaponPrefab = EditorStaticMethods.CreateWeaponObjectInFolder(finalFolderPath, newWeapon); } WeaponParameters newWeaponParameters = null; if (newWeaponPrefab != null) { newWeaponParameters = EditorStaticMethods.CreateWeaponSetInFolder(finalFolderPath, newWeaponName, newWeaponPrefab); } else { newWeaponParameters = EditorStaticMethods.CreateWeaponSetInFolder(finalFolderPath, newWeaponName); } if (newWeaponPrefab != null) { Selection.activeObject = newWeaponPrefab; EditorGUIUtility.PingObject(newWeaponPrefab); // PrefabUtility.LoadPrefabContents(AssetDatabase.GetAssetPath(newWeaponPrefab.GetInstanceID())); } else if (newWeaponParameters != null) { Selection.activeObject = newWeaponParameters; EditorGUIUtility.PingObject(newWeaponParameters); } } } }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); GUILayout.Space(8); serializedObject.Update(); SerializedProperty damageTagProperty = serializedObject.FindProperty("damageTag"); EditorGUILayout.PropertyField(damageTagProperty); serializedObject.ApplyModifiedProperties(); GUILayout.Space(8); EditorGUILayout.LabelField("Inputs", EditorStyles.boldLabel); PlayerShipInputs baseInputs = targetPlayerSpaceShip.GetPlayerShipInputs; PlayerShipInputs newInputs = (PlayerShipInputs)EditorGUILayout.ObjectField ("Inputs", baseInputs, typeof(PlayerShipInputs), false); if (newInputs != baseInputs) { Undo.RecordObject(targetPlayerSpaceShip, "Undo Affect Inputs"); targetPlayerSpaceShip.SetPlayerShipInputs(newInputs); currentInputEditor = null; } PlayerShipInputs finalInputs = targetPlayerSpaceShip.GetPlayerShipInputs; if (finalInputs != null) { if (currentInputEditor == null) { Editor.CreateCachedEditor(finalInputs, typeof(PlayerShipInputsInspector), ref currentInputEditor); } showInputs = EditorGUILayout.BeginFoldoutHeaderGroup(showInputs, (showInputs ? "Close" : "Open") + " Inputs", showInputs ? EditorStyles.boldLabel : null); EditorGUILayout.EndFoldoutHeaderGroup(); if (showInputs) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginVertical("box"); currentInputEditor.OnInspectorGUI(); EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= 1; GUILayout.Space(8); EditorStaticMethods.DrawLine(2, Color.black); } } if (EditorGUI.EndChangeCheck()) { EditorSceneManager.MarkSceneDirty(targetPlayerSpaceShip.gameObject.scene); } base.OnInspectorGUI(); }
public static void ShowProjectileParameters(ProjectileParameters projParameters, float indentValue) { SerializedObject serializedParameters = new SerializedObject(projParameters); serializedParameters.Update(); SerializedProperty speedAttribute = serializedParameters.FindProperty("projectileSpeed"); SerializedProperty lifetimeAttribute = serializedParameters.FindProperty("projectileLifetime"); SerializedProperty sizeAttribute = serializedParameters.FindProperty("projectileSize"); SerializedProperty damagesAttribute = serializedParameters.FindProperty("projectileDamages"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), speedAttribute, new GUIContent(projParameters.GetProjectileSpeed.mode == MinMaxMode.Constant ? "Projectile Speed" : "Random Projectile Speed", projParameters.GetProjectileSpeed.mode == MinMaxMode.Constant ? "The speed of the projectile" : "The speed of the projectile, randomly picked between the two Values")); if (projParameters.GetProjectileSpeed.minValue < 0) { projParameters.ChangeProjectileMinSpeed(0); } if (projParameters.GetProjectileSpeed.maxValue < 0) { projParameters.ChangeProjectileMaxSpeed(0); } EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), lifetimeAttribute, new GUIContent(projParameters.GetProjectileLifetime.mode == MinMaxMode.Constant ? "Projectile Lifetime" : "Random Projectile Lifetime", projParameters.GetProjectileLifetime.mode == MinMaxMode.Constant ? "The lifeTime of the projectile" : "The lifeTime of the projectile, randomly picked between the two Values")); if (projParameters.GetProjectileLifetime.minValue < 0.01f) { projParameters.ChangeProjectileMinLifetime(0.01f); } if (projParameters.GetProjectileLifetime.maxValue < 0.01f) { projParameters.ChangeProjectileMaxLifetime(0.01f); } EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), sizeAttribute); if (projParameters.GetProjectileSize < 0.01f) { projParameters.ChangeSize(0.01f); } EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), damagesAttribute); if (projParameters.GetProjectileDamages < 1) { projParameters.ChangeDamages(1); } serializedParameters.ApplyModifiedProperties(); }
public static void ShowWeaponParameters(WeaponParameters weaponParameters, float indentValue, ref bool showShootParameters, ref bool showProjectileParameters) { SerializedObject serializedParameters = new SerializedObject(weaponParameters); serializedParameters.Update(); #region Base Parameters GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Base Parameters", EditorStyles.boldLabel); SerializedProperty weaponNameAttribute = serializedParameters.FindProperty("weaponName"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), weaponNameAttribute); SerializedProperty weaponPrefabAttribute = serializedParameters.FindProperty("weaponPrefab"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), weaponPrefabAttribute); #endregion #region Shoot Parameters GUILayout.Space(20); GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Shoot Parameters", EditorStyles.boldLabel); SerializedProperty shootParamsAttribute = serializedParameters.FindProperty("shootParameters"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), shootParamsAttribute); serializedParameters.ApplyModifiedProperties(); ShootParameters shootParams = weaponParameters.GetShootParameters; if (shootParams != null) { showShootParameters = EditorGUI.BeginFoldoutHeaderGroup(EditorStaticMethods.GetIndentedControlRect(indentValue), showShootParameters, (showShootParameters ? "Close" : "Open") + " Shoot Parameters", showShootParameters ? EditorStyles.boldLabel : null); EditorGUI.EndFoldoutHeaderGroup(); if (showShootParameters) { EditorGUILayout.BeginVertical("box"); ShootParametersInspector.ShowShootParameters(shootParams, indentValue + 15, ref showProjectileParameters); EditorGUILayout.EndVertical(); } } #endregion }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); System.Type shipType = targetSpaceShip.GetType(); if (shipType != typeof(PlayerSpaceShipScript)) { GUILayout.Space(8); serializedObject.Update(); SerializedProperty damageTagProperty = serializedObject.FindProperty("damageTag"); EditorGUILayout.PropertyField(damageTagProperty); serializedObject.ApplyModifiedProperties(); } #region Movements GUILayout.Space(8); EditorGUILayout.LabelField("Movement System", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); SpaceShipMovementParameters newMovementParameters = (SpaceShipMovementParameters)EditorGUILayout.ObjectField ("Movement Parameters", targetSpaceShip.GetMovementSystem.GetMovementParameters, typeof(SpaceShipMovementParameters), false); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(targetSpaceShip, "Undo Affect Movement Parameters"); targetSpaceShip.GetMovementSystem.SetMovementParameters(newMovementParameters); } SpaceShipMovementParameters finalMovementParameters = targetSpaceShip.GetMovementSystem.GetMovementParameters; if (finalMovementParameters != null) { showMovementParameters = EditorGUILayout.BeginFoldoutHeaderGroup(showMovementParameters, (showMovementParameters ? "Close" : "Open") + " Movement Parameters", showMovementParameters ? EditorStyles.boldLabel : null); EditorGUILayout.EndFoldoutHeaderGroup(); if (showMovementParameters) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginVertical("box"); SpaceShipMovementParametersInspector.ShowMovementParameters(finalMovementParameters, 10); EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= 1; GUILayout.Space(8); EditorStaticMethods.DrawLine(2, Color.black); } } #endregion #region Shooting GUILayout.Space(8); EditorGUILayout.LabelField("Shooting System", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); Transform newWeaponsParent = (Transform)EditorGUILayout.ObjectField("Weapons Parent", targetSpaceShip.GetShootingSystem.GetWeaponsParent, typeof(Transform), true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(targetSpaceShip, "Undo Affect Weapons Parent"); targetSpaceShip.GetShootingSystem.SetWeaponsParent(newWeaponsParent); } EditorGUI.BeginChangeCheck(); WeaponParameters newWeaponParameters = (WeaponParameters)EditorGUILayout.ObjectField("Weapon Parameters", targetSpaceShip.GetShootingSystem.GetBaseWeaponParameters, typeof(WeaponParameters), false); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(targetSpaceShip, "Undo Affect Weapons Parameters"); targetSpaceShip.GetShootingSystem.SetWeaponParameters(newWeaponParameters); } WeaponParameters finalWeaponParameters = targetSpaceShip.GetShootingSystem.GetBaseWeaponParameters; if (finalWeaponParameters != null) { showWeaponParameters = EditorGUILayout.BeginFoldoutHeaderGroup(showWeaponParameters, (showWeaponParameters ? "Close" : "Open") + " Weapon Parameters", showWeaponParameters ? EditorStyles.boldLabel : null); EditorGUILayout.EndFoldoutHeaderGroup(); if (showWeaponParameters) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginVertical("box"); WeaponParametersInspector.ShowWeaponParameters(finalWeaponParameters, 15, ref showShootParameters, ref showProjectileParameters); EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= 1; GUILayout.Space(8); EditorStaticMethods.DrawLine(2, Color.black); } } #endregion #region Others GUILayout.Space(8); EditorGUILayout.LabelField("Other References", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); DamageableComponent newLinkedDamagesComponent = (DamageableComponent)EditorGUILayout.ObjectField("Linked Damageable Component", targetSpaceShip.GetRelatedDamageableComponent, typeof(DamageableComponent), true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(targetSpaceShip, "Change Damageable Component"); targetSpaceShip.SetRelatedDamageableComponent(newLinkedDamagesComponent); } if (targetSpaceShip.GetRelatedDamageableComponent != null) { EditorGUI.BeginChangeCheck(); int newLifeAmount = EditorGUILayout.IntField("Ship Life Amount", targetSpaceShip.GetRelatedDamageableComponent.GetMaxLifeAmount); if (EditorGUI.EndChangeCheck()) { Debug.Log("Life Amount Changed"); Undo.RecordObject(targetSpaceShip.GetRelatedDamageableComponent, "Undo Change Max Life Amount"); targetSpaceShip.GetRelatedDamageableComponent.SetMaxLifeAmount(newLifeAmount); } } #endregion if (EditorGUI.EndChangeCheck()) { EditorSceneManager.MarkSceneDirty(targetSpaceShip.gameObject.scene); } //base.OnInspectorGUI(); }
private void OnGUI() { EditorStaticMethods.ShowFolderAndAskIfCreateNew(ref selectedFolderRef, ref createFolder); float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth *= 1.5f; GUILayout.Space(8); GUILayout.Label("Enemy Parameters", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); newEnemyName = EditorGUILayout.TextField("New Enemy Name", newEnemyName); if (EditorGUI.EndChangeCheck()) { newWeaponName = newEnemyName + " Weapon"; } enemyCreationParameters.enemyIdentifyingColor = EditorGUILayout.ColorField("Enemy Identifying Color", enemyCreationParameters.enemyIdentifyingColor); enemyCreationParameters.lifeAmount = EditorGUILayout.IntField("Life Amount", enemyCreationParameters.lifeAmount); enemyCreationParameters.aimingType = (EnemyAimingType)EditorGUILayout.EnumPopup(new GUIContent("Aiming Type"), enemyCreationParameters.aimingType); GUILayout.Space(8); GUILayout.Label("Linked Weapon", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); createLinkedWeaponParameters = EditorGUILayout.Toggle("Create Linked Weapon Parameters", createLinkedWeaponParameters); if (EditorGUI.EndChangeCheck()) { newWeaponName = newEnemyName + " Weapon"; } if (createLinkedWeaponParameters) { EditorGUI.indentLevel++; GUILayout.BeginVertical("box"); WeaponSetCreationWindow.ShowWeaponSetCreationParameters(selectedFolderRef, ref newWeaponName, false, ref createLinkedWeaponObject, ref newWeaponCreationParameters); EditorGUI.indentLevel--; GUILayout.EndVertical(); } GUILayout.Space(16); if (selectedFolderRef != null) { if (GUILayout.Button("Create the new Enemy : \"" + newEnemyName + "\" !")) { string finalFolderPath = selectedFolderRef.GetFolderPath(); if (createFolder) { string folderCreationPath = finalFolderPath; finalFolderPath = AssetDatabase.GenerateUniqueAssetPath(finalFolderPath + "/" + newEnemyName + " Set"); AssetDatabase.CreateFolder(folderCreationPath, newEnemyName + " Set"); } EnemySpaceShipScript newEnemyTempObj = EnemyCreationParameters.ComposeEnemy(enemyCreationParameters, newEnemyName); EnemySpaceShipScript newEnemyPrefab = EditorStaticMethods.CreateEnemyPrefabInFolder(finalFolderPath, newEnemyTempObj); if (newEnemyPrefab == null) { Debug.LogError("Couldn't create enemy Set"); return; } WeaponScript newWeaponPrefab = null; if (createLinkedWeaponObject) { WeaponScript newWeapon = WeaponCreationParameters.ComposeWeapon(newWeaponCreationParameters, newWeaponName); newWeaponPrefab = EditorStaticMethods.CreateWeaponObjectInFolder(finalFolderPath, newWeapon); } WeaponParameters newWeaponParameters = null; if (newWeaponPrefab != null) { newWeaponParameters = EditorStaticMethods.CreateWeaponSetInFolder(finalFolderPath, newWeaponName, newWeaponPrefab); } else { newWeaponParameters = EditorStaticMethods.CreateWeaponSetInFolder(finalFolderPath, newWeaponName); } newEnemyPrefab.GetShootingSystem.SetWeaponParameters(newWeaponParameters); Selection.activeObject = newEnemyPrefab; EditorGUIUtility.PingObject(newEnemyPrefab); #region Library //LevelPrefabsLibrary enemiesLibrary = AssetDatabase.LoadAssetAtPath("Assets/Resources/Level Prefabs Library.asset", typeof(LevelPrefabsLibrary)) as LevelPrefabsLibrary; ScriptableObject library = Resources.Load("Level Prefabs Library") as ScriptableObject; LevelPrefabsLibrary prefabsLibrary = library as LevelPrefabsLibrary; if (prefabsLibrary == null) { Debug.LogError("Library Not Found"); return; } prefabsLibrary.AddEnemyPrefabInformations(newEnemyPrefab.gameObject, enemyCreationParameters.enemyIdentifyingColor); EditorUtility.SetDirty(prefabsLibrary); #endregion } } EditorGUIUtility.labelWidth = oldWidth; }
public void ShowChunkGrid(Vector2 gridStartPos) { Color baseGUIColor = GUI.color; EditorGUI.BeginChangeCheck(); List <List <int> > chunkTab = targetChunkData.ListIntoTab(targetChunkData.GetChunkContent); float spacing = 5; float tileWidth = (EditorGUIUtility.currentViewWidth / numberOfColumns) - 10; float tileHeight = tileWidth; GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, (chunkTab.Count + 1) * (tileHeight + spacing) + 20); bool needToRepaint = false; if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { leftMouseIsDown = true; } else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { leftMouseIsDown = false; } if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { rightMouseIsDown = true; } else if (Event.current.type == EventType.MouseUp && Event.current.button == 1) { rightMouseIsDown = false; } for (int y = 0; y < chunkTab.Count; y++) { List <int> line = chunkTab[y]; for (int x = 0; x < line.Count; x++) { int oldValue = chunkTab[y][x]; Rect rect = new Rect(gridStartPos.x + (tileWidth + spacing) * x, gridStartPos.y + (tileWidth + spacing) * y, tileWidth, tileHeight); bool leftMouseIsDownOnRect = false; bool rightMouseIsDownOnRect = false; if (leftMouseIsDown) { leftMouseIsDownOnRect = EditorStaticMethods.CheckIfMouseInRect(rect); if (!Event.current.alt) { if (currentTargetTileIndexes != new Vector2(x, y)) { currentTargetTileIndexes = new Vector2(x, y); } if (leftMouseIsDownOnRect) { chunkTab[y][x] = currentBrushIndex; } } else { if (leftMouseIsDownOnRect) { SetCurrentBrushIndex(chunkTab[y][x]); needToRepaint = true; } } } else if (rightMouseIsDown) { rightMouseIsDownOnRect = EditorStaticMethods.CheckIfMouseInRect(rect); if (currentTargetTileIndexes != new Vector2(x, y)) { currentTargetTileIndexes = new Vector2(x, y); } if (rightMouseIsDownOnRect) { chunkTab[y][x] = 0; } } int tileValue = chunkTab[y][x]; GUIStyle labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.fontSize = (int)(tileWidth * 0.2f); Color tileColor = Color.white; string tileName = "/"; if (prefabsDictionnary.ContainsKey(tileValue)) { LevelPrefabInformations tileInfo = prefabsDictionnary[tileValue]; tileColor = tileInfo.elementAttributedColor; tileName = tileInfo.elementName; } EditorGUI.DrawRect(rect, tileColor); EditorGUI.LabelField(rect, tileName, labelStyle); if (oldValue != tileValue) { needToRepaint = true; } } } if (needToRepaint) { Undo.RecordObject(targetChunkData, "Undo Chunk Modification"); targetChunkData.SetChunkContent(targetChunkData.TabIntoList(chunkTab)); EditorUtility.SetDirty(targetChunkData); Repaint(); } GUI.color = baseGUIColor; }
public static void ShowShootParameters(ShootParameters shootParameters, float indentValue, ref bool showProjectileParameters) { SerializedObject serializedParameters = new SerializedObject(shootParameters); serializedParameters.Update(); #region Base Parameters GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Base Parameters", EditorStyles.boldLabel); SerializedProperty projectilePrefabAttribute = serializedParameters.FindProperty("projectilePrefab"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), projectilePrefabAttribute); SerializedProperty cadenceProperty = serializedParameters.FindProperty("shootCadence"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), cadenceProperty, new GUIContent("Shoot Cadence", "The reloading time needed after a shot to be able to shoot again")); if (cadenceProperty.floatValue < 0) { cadenceProperty.floatValue = 0; } SerializedProperty numberOfProjectilesPerShotProperty = serializedParameters.FindProperty("numberOfProjectilesPerShot"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), numberOfProjectilesPerShotProperty, new GUIContent("Number of Projectiles per Shot", "The number of projectile that will be instantiated on shot by each shoot origins of the weapon. Generaly of one except for shotguns")); if (numberOfProjectilesPerShotProperty.intValue < 1) { numberOfProjectilesPerShotProperty.intValue = 1; } SerializedProperty imprecisionAngleProperty = serializedParameters.FindProperty("imprecisionAngle"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), imprecisionAngleProperty, new GUIContent("Imprecision Angle", "The angle of the cone in which the projectile direction will be randomly picked on shot. Set low for precise shots, set high for spray")); if (imprecisionAngleProperty.floatValue < 0) { imprecisionAngleProperty.floatValue = 0; } #endregion #region Serial Shots GUILayout.Space(20); GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Serial Shots", EditorStyles.boldLabel); SerializedProperty numberOfSerialShotsProperty = serializedParameters.FindProperty("numberOfSerialShots"); bool isSerialShot = EditorGUI.Toggle(EditorStaticMethods.GetIndentedControlRect(indentValue), new GUIContent("Is Serial Shots", "Set true if you want a burst shot"), numberOfSerialShotsProperty.intValue > 1); if (isSerialShot) { if (numberOfSerialShotsProperty.intValue < 2) { numberOfSerialShotsProperty.intValue = 3; } EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), numberOfSerialShotsProperty, new GUIContent("Number of Shots", "The number of shots that will be done through the burst shot")); SerializedProperty timeBetweenEachSerialShotProperty = serializedParameters.FindProperty("timeBetweenEachSerialShot"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), timeBetweenEachSerialShotProperty, new GUIContent("Time between each Shot", "The time between two shots of the burst shot")); if (numberOfSerialShotsProperty.intValue < 2) { numberOfSerialShotsProperty.intValue = 2; } if (timeBetweenEachSerialShotProperty.floatValue < 0) { timeBetweenEachSerialShotProperty.floatValue = 0; } } else { if (numberOfSerialShotsProperty.intValue != 1) { numberOfSerialShotsProperty.intValue = 1; } } #endregion #region Projectile Parameters GUILayout.Space(20); GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Projectiles Parameters", EditorStyles.boldLabel); SerializedProperty projParamsAttribute = serializedParameters.FindProperty("projectileParameters"); EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), projParamsAttribute); serializedParameters.ApplyModifiedProperties(); ProjectileParameters projParams = shootParameters.GetProjectileParameters; if (projParams != null) { showProjectileParameters = EditorGUI.BeginFoldoutHeaderGroup(EditorStaticMethods.GetIndentedControlRect(indentValue), showProjectileParameters, (showProjectileParameters ? "Close" : "Open") + " Projectile Parameters", showProjectileParameters ? EditorStyles.boldLabel : null); EditorGUI.EndFoldoutHeaderGroup(); if (showProjectileParameters) { EditorGUILayout.BeginVertical("box"); ProjectileParametersInspector.ShowProjectileParameters(projParams, indentValue + 15); EditorGUILayout.EndVertical(); } } #endregion }
public void GenerateQuests() { string rawContent = questsSpreadsheet.text; string[] lineList = rawContent.Split(new string[] { "\n" }, System.StringSplitOptions.None); string baseTargetFolderPath = selectedFolderRef.GetFolderPath(); string finalTargetFolderPath = baseTargetFolderPath; Object questsLibraryObject = Resources.Load("Quests/Quests Library"); QuestsLibrary questsLibrary = questsLibraryObject != null ? questsLibraryObject as QuestsLibrary : null; for (int i = 1; i < lineList.Length; i++) { finalTargetFolderPath = baseTargetFolderPath; string rawLine = lineList[i]; Quest newQuest = ScriptableObject.CreateInstance <Quest>(); string[] rawElements = rawLine.Split(new string[] { ";" }, System.StringSplitOptions.None); if (rawElements.Length < 6) { break; } newQuest.questName = rawElements[0]; newQuest.questDescription = rawElements[1]; newQuest.questType = (QuestType)System.Enum.Parse(typeof(QuestType), rawElements[2], true); newQuest.questRealisationType = (QuestRealisationType)System.Enum.Parse(typeof(QuestRealisationType), rawElements[3], true); int valueToReach = 0; int.TryParse(rawElements[4], out valueToReach); newQuest.valueToReach = valueToReach; string setName = rawElements[5]; if (setName[setName.Length - 1].GetHashCode() == 851981) { setName = setName.Substring(0, setName.Length - 1); } if (createSetFolders && !string.IsNullOrEmpty(setName)) { finalTargetFolderPath += "/" + setName; if (!AssetDatabase.IsValidFolder(finalTargetFolderPath)) { AssetDatabase.CreateFolder(baseTargetFolderPath, setName); } } EditorStaticMethods.CreateOrReplaceQuestInFolder(finalTargetFolderPath, newQuest); if (questsLibrary != null) { questsLibrary.AddToLibrary(newQuest, setName); } } Debug.Log("Succesfully loaded !"); }