Editor First Commit
This commit is contained in:
parent
59c1924fab
commit
810d621fcd
@ -12,9 +12,9 @@ namespace Syntriax.Modules.Movement.Config
|
||||
/// </remarks>
|
||||
public class MovementDefinitionFactory : MonoBehaviour
|
||||
{
|
||||
private const string Name = "Movement Definition Factory";
|
||||
private const int InitialCapacity = 64;
|
||||
private const string ResourceDirectoryToDefinitions = "Modules/Syntriax/Movement/Definitions/";
|
||||
internal const string Name = "Movement Definition Factory";
|
||||
internal const int InitialCapacity = 64;
|
||||
internal const string ResourceDirectoryToDefinitions = "Modules/Syntriax/Movement/Definitions/";
|
||||
|
||||
private static MovementDefinitionFactory _instance = null;
|
||||
public static MovementDefinitionFactory Instance
|
||||
@ -137,7 +137,7 @@ namespace Syntriax.Modules.Movement.Config
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void SaveMovementDefinition(MovementDefinition definition)
|
||||
public static void SaveMovementDefinition(MovementDefinition definition)
|
||||
{
|
||||
string jsonText = JsonUtility.ToJson(definition, true);
|
||||
string path = $"Assets/Resources/{ResourceDirectoryToDefinitions}{definition.Name}.json";
|
||||
|
8
Editor.meta
Normal file
8
Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d295c54744337740b623590636ad11a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
51
Editor/CreateMovementDefinitionEditor.cs
Normal file
51
Editor/CreateMovementDefinitionEditor.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Editor
|
||||
{
|
||||
public class CreateMovementDefinitionEditor : EditorWindow
|
||||
{
|
||||
ReorderableList list;
|
||||
|
||||
[MenuItem("Syntriax/Modules/Create Movement Definition")]
|
||||
private static void ShowWindow()
|
||||
{
|
||||
var window = GetWindow<CreateMovementDefinitionEditor>();
|
||||
window.titleContent = new GUIContent("Create Movement Definition");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Definition Name");
|
||||
string definitionName = GUILayout.TextField("Movement Definition");
|
||||
|
||||
GUILayout.Space(10);
|
||||
bool createButtonPressed = GUILayout.Button("Create");
|
||||
|
||||
if (!createButtonPressed)
|
||||
return;
|
||||
|
||||
string resourceDirectoryToDefinitions = Movement.Config.MovementDefinitionFactory.ResourceDirectoryToDefinitions;
|
||||
string[] folders = resourceDirectoryToDefinitions.Split('/');
|
||||
|
||||
string currentPath = "Assets/Resources";
|
||||
CreateSubFolder("Assets", "Resources");
|
||||
foreach (string folder in folders)
|
||||
{
|
||||
CreateSubFolder(currentPath, folder);
|
||||
currentPath += $"/{folder}";
|
||||
}
|
||||
|
||||
currentPath += $"/{definitionName}.json";
|
||||
Movement.Config.MovementDefinitionFactory.SaveMovementDefinition(new Config.MovementDefinition(definitionName, new Config.MovementConfig[0], new string[0]));
|
||||
}
|
||||
|
||||
private static void CreateSubFolder(string parentFolder, string subFolder)
|
||||
{
|
||||
if (!AssetDatabase.IsValidFolder($"{parentFolder}/{subFolder}"))
|
||||
AssetDatabase.CreateFolder(parentFolder, subFolder);
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/CreateMovementDefinitionEditor.cs.meta
Normal file
11
Editor/CreateMovementDefinitionEditor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e6c6eea597fd2d4e96946897f9a0bd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user