public override void OnInspectorGUI() { Weapon launcher = (Weapon)target; serializedObject.Update(); EditorGUILayout.Space(); if (EditorApplication.isPlaying) { string label = "Shoot"; if (launcher.isShooting) { label = "Stop shoot"; } if (GUILayout.Button(label)) { if (launcher.isShooting) { launcher.StopShoot(); } else { launcher.Shoot(); } } } #region Properties showProperties.boolValue = EditorTools.BeginFoldOut("Properties", showProperties.boolValue); if (showProperties.boolValue || showProperties.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { // Autonomous EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(isAutonomous, new GUIContent("Autonomous")); EditorGUI.indentLevel++; if (isAutonomous.boolValue) { EditorGUILayout.HelpBox("Radar component required", MessageType.Info); factionIndex = EditorGUILayout.Popup("Faction", factionIndex, factionLabels); if (factionIndex > -1) { faction.objectReferenceValue = (UnityEngine.Object)factions[factionIndex]; } } EditorGUI.indentLevel--; EditorGUILayout.Space(); // Weapon EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(ammunition); if (EditorGUI.EndChangeCheck()) { if (ammunition.objectReferenceValue != null) { if (ammunition.objectReferenceValue.GetType() == typeof(LaserBeam)) { weaponType.enumValueIndex = 1; } else { weaponType.enumValueIndex = 0; } } } // Fire Rate if (weaponType.enumValueIndex == 0) { EditorGUILayout.PropertyField(fireRate, new GUIContent("Fire Rate /s")); } EditorGUILayout.Space(); // Barrels EditorGUILayout.PropertyField(isSynchronizedBarrel, new GUIContent("Synchronized barrel")); EditorGUILayout.PropertyField(fpsAlignment); EditorGUILayout.PropertyField(fixedAlignment); if (fixedAlignment.boolValue) { EditorGUILayout.PropertyField(alignmentPoint); } EditorGUI.indentLevel++; EditorGUILayout.PropertyField(barrels, true); EditorGUI.indentLevel--; } EditorTools.EndGroup(); } #endregion #region Weapon Mode if (weaponType.enumValueIndex == 0) { showMode.boolValue = EditorTools.BeginFoldOut("Mode", showMode.boolValue); if (showMode.boolValue || showMode.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(isOneShot, new GUIContent("One shot")); EditorGUILayout.PropertyField(isBurst, new GUIContent("Burst")); if (isBurst.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(burstShotsAmount, new GUIContent("Amount")); EditorGUI.indentLevel--; } EditorGUILayout.PropertyField(isFullyAutmotic, new GUIContent("Automatic")); } EditorTools.EndGroup(); } } #endregion #region Magazine showMagazine.boolValue = EditorTools.BeginFoldOut("Magazine", showMagazine.boolValue); if (showMagazine.boolValue || showMagazine.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(enableMagazine, new GUIContent("Enable")); if (enableMagazine.boolValue) { string shotValueLabel = "Shot value"; string reloadValueLabel = "Reload Time"; if (magazineType.enumValueIndex == 1) { shotValueLabel = "Speed"; reloadValueLabel = "Reload speed"; } EditorGUILayout.PropertyField(magazineType, new GUIContent("Type")); if (weaponType.enumValueIndex == 1) { magazineType.enumValueIndex = 1; } EditorGUILayout.PropertyField(magazineCapacity, new GUIContent("Capacity ")); EditorGUILayout.PropertyField(shotValue, new GUIContent(shotValueLabel)); EditorGUILayout.Space(); EditorGUILayout.PropertyField(magazineAutoReload, new GUIContent("Auto reload")); EditorGUILayout.PropertyField(reloadValue, new GUIContent(reloadValueLabel)); } } EditorTools.EndGroup(); } #endregion #region Ammunition stock if (enableMagazine.boolValue && magazineType.enumValueIndex == 0) { showStock.boolValue = EditorTools.BeginFoldOut("Stock of ammuntion", showStock.boolValue); if (showStock.boolValue) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(enableAmmunitionStock, new GUIContent("Enable")); EditorGUILayout.PropertyField(ammunitionMaxStock, new GUIContent("Max Stock")); EditorGUILayout.PropertyField(ammunitionStock, new GUIContent("Initial stock")); } EditorTools.EndGroup(); } } #endregion #region Effect showEffect.boolValue = EditorTools.BeginFoldOut("Effects", showEffect.boolValue); if (showEffect.boolValue || showEffect.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(muzzleEffect); EditorGUILayout.PropertyField(startShootingEffect); EditorGUILayout.PropertyField(StopShootingEffect); } EditorTools.EndGroup(); } #endregion #region event showEvents.boolValue = EditorTools.BeginFoldOut("Events", showEvents.boolValue); if (showEvents.boolValue || showEvents.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(onStartShooting, true); EditorGUILayout.PropertyField(onShooting, true); EditorGUILayout.PropertyField(onStopShooting, true); EditorGUILayout.PropertyField(onReload, true); EditorGUILayout.PropertyField(OnAutoReload, true); EditorGUILayout.PropertyField(onNeedReload, true); EditorGUILayout.PropertyField(OnReloadEnd, true); } EditorTools.EndGroup(); } #endregion serializedObject.ApplyModifiedProperties(); if (GUI.changed && !EditorApplication.isPlaying) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } GUI.enabled = true; }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); #region Properties showProperties.boolValue = EditorTools.BeginFoldOut("Properties", showProperties.boolValue); if (showProperties.boolValue || showProperties.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(autonomous); EditorGUILayout.PropertyField(autoTarget); EditorGUILayout.PropertyField(autoReTarget, new GUIContent("Auto re-target")); if (autoTarget.boolValue || autoTarget.hasMultipleDifferentValues || autoReTarget.boolValue || autoReTarget.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(maxMissileOnTarget, new GUIContent("Max on target")); } if (autoTarget.boolValue) { EditorGUILayout.HelpBox("Radar component required", MessageType.Info); } //Life time EditorGUILayout.PropertyField(lifeTime); // Layer mash EditorGUILayout.PropertyField(layerMask); //subweapon EditorGUILayout.PropertyField(subWeapon); } EditorTools.EndGroup(); } #endregion #region Damage showDamage.boolValue = EditorTools.BeginFoldOut("Damage", showDamage.boolValue); if (showDamage.boolValue || showDamage.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { // Damge EditorGUILayout.PropertyField(projectileDamage, new GUIContent("At")); // Type EditorGUILayout.PropertyField(damageType, new GUIContent("Type")); if (damageType.enumValueIndex == 1) { EditorGUILayout.PropertyField(damageRadius, new GUIContent("Explosion radius")); } // Nature if (!damageNature.hasMultipleDifferentValues) { damageNature.intValue = EditorGUILayout.Popup("Nature", damageNature.intValue, damageLabels); } else { int tmpDamageNature = EditorGUILayout.Popup("Nature", -1, damageLabels); if (tmpDamageNature != damageNature.intValue && tmpDamageNature > -1) { damageNature.intValue = tmpDamageNature; } } EditorGUILayout.Space(); EditorGUILayout.PropertyField(randomDamagePoint, new GUIContent("Random damage")); if (!randomDamagePoint.hasMultipleDifferentValues) { if (!randomDamagePoint.boolValue) { EditorGUILayout.PropertyField(damagePoint, new GUIContent("Point")); } else { EditorGUILayout.PropertyField(damagePoint, new GUIContent("Min Point")); EditorGUILayout.PropertyField(damagePointMax, new GUIContent("Max Point")); } } else { EditorGUILayout.PropertyField(damagePoint, new GUIContent("Point")); EditorGUILayout.PropertyField(damagePointMax, new GUIContent("Max Point")); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(isPhysic, new GUIContent("Add force at impact")); if (isPhysic.boolValue || isPhysic.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(force); EditorGUILayout.PropertyField(forceMode); } } EditorTools.EndGroup(); } #endregion #region Projectile physic showPhysic.boolValue = EditorTools.BeginFoldOut("Physic", showPhysic.boolValue); if (showPhysic.boolValue || showPhysic.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(useAdvance); EditorGUILayout.PropertyField(velocity, new GUIContent("Velocity")); EditorGUILayout.PropertyField(straightTime, new GUIContent("Straight time (s)")); EditorGUILayout.PropertyField(angularSpeed); EditorGUILayout.PropertyField(chaos); EditorGUILayout.PropertyField(chaosFrenquency); EditorGUILayout.Space(); EditorGUILayout.PropertyField(rayAdvance, new GUIContent("Ray Advance")); EditorGUILayout.PropertyField(rayRadius, new GUIContent("Ray radius")); } EditorTools.EndGroup(); } #endregion #region Effect showEffect.boolValue = EditorTools.BeginFoldOut("Effects", showEffect.boolValue); if (showEffect.boolValue || showEffect.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(impactEffect); EditorGUILayout.PropertyField(deathEffect); EditorGUILayout.Space(); EditorGUILayout.PropertyField(timedEffect); EditorGUILayout.PropertyField(time); } EditorTools.EndGroup(); } #endregion serializedObject.ApplyModifiedProperties(); if (GUI.changed && !EditorApplication.isPlaying) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } }
public override void OnInspectorGUI() { EditorGUILayout.Space(); serializedObject.Update(); #region Properties showPropertie.boolValue = EditorTools.BeginFoldOut("Entity properties", showPropertie.boolValue); if (showPropertie.boolValue || showPropertie.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(subEntity); if (subEntity.boolValue || subEntity.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(parentEntity); } if (!subEntity.boolValue || subEntity.hasMultipleDifferentValues) { // Faction if (!faction.hasMultipleDifferentValues) { factionIndex = EditorGUILayout.Popup("Faction", factionIndex, factionLabels); if (factionIndex > -1) { faction.objectReferenceValue = (UnityEngine.Object)factions[factionIndex]; } } else { int tmpfactionIndex = EditorGUILayout.Popup("Faction", -1, factionLabels); if (tmpfactionIndex != factionIndex && tmpfactionIndex > -1) { factionIndex = tmpfactionIndex; faction.objectReferenceValue = (UnityEngine.Object)factions[factionIndex]; } } // Type EditorGUILayout.PropertyField(entityType, new GUIContent("Type")); } EditorGUILayout.Space(); // invulnerableSpawn at spawn EditorGUILayout.PropertyField(isInvulnerable, new GUIContent("Invulnerable")); EditorGUILayout.Space(); // Life if (!isInvulnerable.boolValue || isInvulnerable.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(randomLife); if (!randomLife.boolValue || randomLife.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(life, new GUIContent("life")); } if (randomLife.boolValue || randomLife.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(rndMinLife, new GUIContent("Min life")); EditorGUILayout.PropertyField(rndMaxLife, new GUIContent("Max life")); } EditorGUILayout.PropertyField(invulnerableSpawn, new GUIContent("Invulnerable spawn time")); EditorGUILayout.PropertyField(scorePoint, new GUIContent("Score Point")); EditorGUILayout.Space(); } // Advanced EditorGUILayout.PropertyField(isPooled, new GUIContent("Managed by a pool")); EditorGUILayout.PropertyField(isExternalEndLife, new GUIContent("External end of life")); } EditorTools.EndGroup(); } #endregion #region Sensitivity to damage showSensitivity.boolValue = EditorTools.BeginFoldOut("Sensitivity to damage", showSensitivity.boolValue); if (showSensitivity.boolValue || showSensitivity.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(addForceFromImpact, new GUIContent("Enable force from impact")); EditorGUILayout.PropertyField(damageThreshold, new GUIContent("DamageThreshold")); EditorGUILayout.Space(); EditorGUILayout.LabelField("Natures", EditorStyles.boldLabel); for (int i = 0; i < damagesSensitivity.arraySize; i++) { EditorGUILayout.PropertyField(damagesSensitivity.GetArrayElementAtIndex(i), new GUIContent(damageLabels[i])); } } EditorTools.EndGroup(); } #endregion #region Damage showDamage.boolValue = EditorTools.BeginFoldOut("Damage on collision", showDamage.boolValue); if (showDamage.boolValue || showDamage.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(isCollisionDamage, new GUIContent("Enable")); EditorGUI.indentLevel++; if (isCollisionDamage.boolValue || isCollisionDamage.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(useTrigger); if (!damageNature.hasMultipleDifferentValues) { damageNature.intValue = EditorGUILayout.Popup("Damage nature", damageNature.intValue, damageLabels); } else { int tmpDamageNature = EditorGUILayout.Popup("Damage nature", -1, damageLabels); if (tmpDamageNature != damageNature.intValue && tmpDamageNature > -1) { damageNature.intValue = tmpDamageNature; } } EditorGUILayout.PropertyField(damagePoint, new GUIContent("Damage Point")); } EditorGUI.indentLevel--; } EditorTools.EndGroup(); } #endregion #region Effect showEffect.boolValue = EditorTools.BeginFoldOut("Effects", showEffect.boolValue); if (showEffect.boolValue || showEffect.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { //spawnEffectOffset = serializedObject.FindProperty("spawnEffectOffset"); //healEffectOffset = serializedObject.FindProperty("healEffectOffset"); //hitEffectOffset = serializedObject.FindProperty("hitEffectOffset"); //deathEffectOffset = serializedObject.FindProperty("deathEffectOffset"); // Spawn EditorGUI.indentLevel++; EditorGUILayout.PropertyField(spawnEffect); if (spawnEffect.isExpanded) { EditorGUILayout.PropertyField(spawnEffectOffset, new GUIContent("Offset")); SerializedProperty spawnE = serializedObject.FindProperty("spawnEffects"); EditorGUILayout.Space(); spawnE.Next(true); spawnE.Next(true); EditorGUILayout.PropertyField(spawnE); for (int i = 0; i < spawnEffect.arraySize; i++) { EditorGUILayout.PropertyField(spawnEffect.GetArrayElementAtIndex(i)); } } EditorGUI.indentLevel--; EditorGUILayout.Space(); // hit EditorGUI.indentLevel++; EditorGUILayout.PropertyField(hitEffect); if (hitEffect.isExpanded) { EditorGUILayout.PropertyField(hitEffectOffset, new GUIContent("Offset")); SerializedProperty hitE = serializedObject.FindProperty("hitEffects"); EditorGUILayout.Space(); hitE.Next(true); hitE.Next(true); EditorGUILayout.PropertyField(hitE); for (int i = 0; i < hitEffect.arraySize; i++) { EditorGUILayout.PropertyField(hitEffect.GetArrayElementAtIndex(i)); } } EditorGUI.indentLevel--; EditorGUILayout.Space(); // Heal EditorGUI.indentLevel++; EditorGUILayout.PropertyField(healEffect); if (healEffect.isExpanded) { EditorGUILayout.PropertyField(healEffectOffset, new GUIContent("Offset")); SerializedProperty healE = serializedObject.FindProperty("healEffects"); EditorGUILayout.Space(); healE.Next(true); healE.Next(true); EditorGUILayout.PropertyField(healE); for (int i = 0; i < healEffect.arraySize; i++) { EditorGUILayout.PropertyField(healEffect.GetArrayElementAtIndex(i)); } } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(deathEffect); if (deathEffect.isExpanded) { EditorGUILayout.PropertyField(deathEffectOffset, new GUIContent("Offset")); SerializedProperty deathE = serializedObject.FindProperty("deathEffects"); EditorGUILayout.Space(); deathE.Next(true); deathE.Next(true); EditorGUILayout.PropertyField(deathE, true); for (int i = 0; i < deathEffect.arraySize; i++) { EditorGUILayout.PropertyField(deathEffect.GetArrayElementAtIndex(i)); } } EditorGUI.indentLevel--; } EditorTools.EndGroup(); } #endregion #region Events showEvent.boolValue = EditorTools.BeginFoldOut("Events", showEvent.boolValue); if (showEvent.boolValue || showEvent.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(onEntitySpawn, true); EditorGUILayout.PropertyField(onHit, true); EditorGUILayout.PropertyField(onHeal, true); EditorGUILayout.PropertyField(onEntityDestroy, true); } EditorTools.EndGroup(); } #endregion serializedObject.ApplyModifiedProperties(); if (GUI.changed && !EditorApplication.isPlaying) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); #region Properties //GUILayout.Toggle(true,"<b><size=11>" + "Properties" + "</size></b>","dragtab"); showProperties.boolValue = EditorTools.BeginFoldOut("Properties", showProperties.boolValue); if (showProperties.boolValue || showProperties.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { // Type EditorGUILayout.PropertyField(projectileType, new GUIContent("Type")); // Life if (projectileType.enumValueIndex != 1) { EditorGUILayout.PropertyField(lifeTime); } // Layer mash EditorGUILayout.PropertyField(layerMask); //subweapon if (projectileType.enumValueIndex != 1) { EditorGUILayout.PropertyField(subWeapon); } } EditorTools.EndGroup(); } #endregion #region Damage //GUILayout.Toggle(true,"<b><size=11>" + "Damage" + "</size></b>","dragtab"); showDamage.boolValue = EditorTools.BeginFoldOut("Damage", showDamage.boolValue); if (showDamage.boolValue || showDamage.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { // Damge EditorGUILayout.PropertyField(projectileDamage, new GUIContent("At")); // Type EditorGUILayout.PropertyField(damageType, new GUIContent("Type")); if (damageType.enumValueIndex == 1) { EditorGUILayout.PropertyField(damageRadius, new GUIContent("Explosion radius")); } // Nature if (!damageNature.hasMultipleDifferentValues) { damageNature.intValue = EditorGUILayout.Popup("Nature", damageNature.intValue, damageLabels); } else { int tmpDamageNature = EditorGUILayout.Popup("Nature", -1, damageLabels); if (tmpDamageNature != damageNature.intValue && tmpDamageNature > -1) { damageNature.intValue = tmpDamageNature; } } EditorGUILayout.Space(); EditorGUILayout.PropertyField(randomDamagePoint, new GUIContent("Random damage")); if (!randomDamagePoint.hasMultipleDifferentValues) { if (!randomDamagePoint.boolValue) { EditorGUILayout.PropertyField(damagePoint, new GUIContent("Point")); } else { EditorGUILayout.PropertyField(damagePoint, new GUIContent("Min Point")); EditorGUILayout.PropertyField(damagePointMax, new GUIContent("Max Point")); } } else { EditorGUILayout.PropertyField(damagePoint, new GUIContent("Point")); EditorGUILayout.PropertyField(damagePointMax, new GUIContent("Max Point")); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(isPhysic, new GUIContent("Add force at impact")); if (isPhysic.boolValue || isPhysic.hasMultipleDifferentValues) { EditorGUILayout.PropertyField(force); EditorGUILayout.PropertyField(forceMode); } } EditorTools.EndGroup(); } #endregion #region Projectile physic //GUILayout.Toggle(true,"<b><size=11>" + "Projectile physic" + "</size></b>","dragtab"); showPhysic.boolValue = EditorTools.BeginFoldOut("Physic", showPhysic.boolValue); if (showPhysic.boolValue || showPhysic.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { //Velocity, Instant, Physic, Guided switch (projectileType.enumValueIndex) { // Velocity case 0: EditorGUILayout.PropertyField(velocity, new GUIContent("Velocity (km/h)")); EditorGUILayout.PropertyField(rayAdvance, new GUIContent("Ray Advance")); EditorGUILayout.PropertyField(rayRadius, new GUIContent("Ray radius")); break; // Instant case 1: EditorGUILayout.PropertyField(rayAdvance, new GUIContent("Distance")); EditorGUILayout.PropertyField(rayRadius, new GUIContent("Ray radius")); break; // Physic case 2: EditorGUILayout.PropertyField(velocity, new GUIContent("shooting Force")); EditorGUILayout.PropertyField(projectileForceMode, new GUIContent("Force mode")); break; } } EditorTools.EndGroup(); } #endregion #region Effect //GUILayout.Toggle(true,"<b><size=11>" + "Effect" + "</size></b>","dragtab"); showEffect.boolValue = EditorTools.BeginFoldOut("Effects", showEffect.boolValue); if (showEffect.boolValue || showEffect.hasMultipleDifferentValues) { EditorTools.BeginGroup(); { EditorGUILayout.PropertyField(impactEffect); EditorGUILayout.PropertyField(deathEffect); EditorGUILayout.Space(); EditorGUILayout.PropertyField(timedEffect); EditorGUILayout.PropertyField(time); } EditorTools.EndGroup(); } #endregion serializedObject.ApplyModifiedProperties(); if (GUI.changed && !EditorApplication.isPlaying) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } }