-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspector utils, new property drawer system, scriptableobject creation
- Loading branch information
Showing
13 changed files
with
616 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...itorKit/Assets/RoR2EditorKit/Editor/Core/PropertyDrawers/EditorGUILayoutPropertyDrawer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace RoR2EditorKit.Core.PropertyDrawers | ||
{ | ||
/// <summary> | ||
/// Used for lazy creation of property drawer using editor gui layout instead of editor gui. | ||
///<para>This shouldnt be used unless you want a very simple property drawer that doesnt need to be all specific</para> | ||
///<para>May cause spamming in the unity editor console that's caused by using EditorGUILayout instead of EditorGUI.</para> | ||
/// </summary> | ||
public class EditorGUILayoutPropertyDrawer : PropertyDrawer | ||
{ | ||
SerializedProperty serializedProperty; | ||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||
{ | ||
serializedProperty = property; | ||
EditorGUI.BeginProperty(position, label, property); | ||
DrawPropertyDrawer(property); | ||
EditorGUI.EndProperty(); | ||
} | ||
|
||
protected virtual void DrawPropertyDrawer(SerializedProperty property) { } | ||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) | ||
{ | ||
return -2f; | ||
} | ||
|
||
protected void DrawField(string propName) => EditorGUILayout.PropertyField(serializedProperty.FindPropertyRelative(propName), true); | ||
protected void DrawField(SerializedProperty property, string propName) => EditorGUILayout.PropertyField(property.FindPropertyRelative(propName), true); | ||
protected void DrawField(SerializedProperty property) => EditorGUILayout.PropertyField(property, true); | ||
protected void Header(string label) => EditorGUILayout.LabelField(new GUIContent(label), EditorStyles.boldLabel); | ||
protected void Header(string label, string tooltip) => EditorGUILayout.LabelField(new GUIContent(label, tooltip), EditorStyles.boldLabel); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...it/Assets/RoR2EditorKit/Editor/Core/PropertyDrawers/EditorGUILayoutPropertyDrawer.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
RoR2EditorKit/Assets/RoR2EditorKit/Editor/ScriptsForRoR2/ScriptableCreators.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using RoR2; | ||
using RoR2.Skills; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace RoR2EditorKit.RoR2 | ||
{ | ||
/// <summary> | ||
/// Creation of ScriptableObjects that are normally uncreatable in RoR2 | ||
/// </summary> | ||
public static class ScriptableCreators | ||
{ | ||
[MenuItem("Assets/Create/RoR2/UnlockableDef")] | ||
public static void CreateUnlockableDef() | ||
{ | ||
var unlockableDef = ScriptableObject.CreateInstance<UnlockableDef>(); | ||
unlockableDef.cachedName = "New UnlockableDef"; | ||
Util.CreateAssetAtSelectionPath(unlockableDef); | ||
} | ||
|
||
#region skilldefs | ||
[MenuItem("Assets/Create/RoR2/SkillDef/Captain/Orbital")] | ||
public static void CreateOrbital() | ||
{ | ||
CreateSkill<CaptainOrbitalSkillDef>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/Captain/SupplyDrop")] | ||
public static void CreateSupplyDrop() | ||
{ | ||
CreateSkill<CaptainSupplyDropSkillDef>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/Combo")] | ||
public static void CreateCombo() | ||
{ | ||
CreateSkill<ComboSkillDef>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/Conditional")] | ||
public static void CreateConditional() | ||
{ | ||
CreateSkill<ConditionalSkillDef>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/EngiMineDeployer")] | ||
public static void CreateEngiMineDeployer() | ||
{ | ||
CreateSkill<EngiMineDeployerSkill>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/Grounded")] | ||
public static void CreateGrounded() | ||
{ | ||
CreateSkill<GroundedSkillDef>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/LunarReplacements/Detonator")] | ||
public static void CreateDetonator() | ||
{ | ||
CreateSkill<LunarDetonatorSkill>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/LunarReplacements/Primary")] | ||
public static void CreatePrimary() | ||
{ | ||
CreateSkill<LunarPrimaryReplacementSkill>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/LunarReplacements/Secondary")] | ||
public static void CreateSecondary() | ||
{ | ||
CreateSkill<LunarSecondaryReplacementSkill>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/Stepped")] | ||
public static void CreateStepped() | ||
{ | ||
CreateSkill<SteppedSkillDef>(); | ||
} | ||
|
||
[MenuItem("Assets/Create/RoR2/SkillDef/ToolbotWeapon")] | ||
public static void CreateToolbotWeapon() | ||
{ | ||
CreateSkill<ToolbotWeaponSkillDef>(); | ||
} | ||
|
||
private static void CreateSkill<T>() where T : SkillDef | ||
{ | ||
var skillDef = ScriptableObject.CreateInstance<T>(); | ||
var SO = skillDef as ScriptableObject; | ||
SO.name = $"New {typeof(T).Name}"; | ||
skillDef = SO as T; | ||
|
||
Util.CreateAssetAtSelectionPath(skillDef); | ||
} | ||
#endregion | ||
} | ||
} |
File renamed without changes.
27 changes: 0 additions & 27 deletions
27
RoR2EditorKit/Assets/RoR2EditorKit/Editor/ScriptsForRoR2/UnlockableDefCreator.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.