Editor Updated & Cleanup
This commit is contained in:
parent
4305d26d17
commit
f25a9b676b
|
@ -49,7 +49,7 @@ namespace Syntriax.Modules.Movement.Config
|
|||
public void AddAssemblyToFactory(Assembly assembly)
|
||||
{
|
||||
foreach (Type type in assembly.GetTypes().Where(predicate))
|
||||
Types.Add(GetTypeName(type), type);
|
||||
Types.Add(type.FullName, type);
|
||||
}
|
||||
|
||||
public Component AddToGameObject(GameObject gameObject, string name)
|
||||
|
@ -59,13 +59,5 @@ namespace Syntriax.Modules.Movement.Config
|
|||
|
||||
return gameObject.AddComponent(Types[name]);
|
||||
}
|
||||
|
||||
public static string GetTypeName(Type type)
|
||||
{
|
||||
if (string.IsNullOrEmpty(type.Namespace))
|
||||
return type.Name;
|
||||
|
||||
return $"{type.Namespace}.{type.Name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using UnityEditor;
|
|||
using UnityEditorInternal;
|
||||
using Syntriax.Modules.Movement.Config;
|
||||
using System;
|
||||
using Syntriax.Modules.Factory;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Editor
|
||||
{
|
||||
|
@ -55,12 +56,12 @@ namespace Syntriax.Modules.Movement.Editor
|
|||
|
||||
GUILayout.Space(10);
|
||||
|
||||
GUILayout.Label("Tip: MovementConfigs->TypeName and MonoBehaviours have the same naming system");
|
||||
GUILayout.Label("Tip: MovementConfigs->TypeName and MonoBehaviours use the type.FullName value");
|
||||
GUILayout.Label("If under a namespace: \"Namespace.ClassName\"");
|
||||
GUILayout.Label("If not under a namespace: \"ClassName\"");
|
||||
GUILayout.Space(5);
|
||||
GUILayout.Label($"Tip: Apply these to your GameObjects by using {nameof(MovementDefinitionFactory)}");
|
||||
GUILayout.Label($"{nameof(MovementDefinitionFactory)}.Instance.ApplyDefinitionToGameObject(\"{movementName.stringValue}\");");
|
||||
GUILayout.Label($"Tip: Apply these to your GameObjects by using {nameof(MovementDefinitionFactory)} or the {nameof(MovementDefinitionApplier)} component");
|
||||
GUILayout.Label($"{nameof(FactorySingleton<MovementDefinitionFactory>)}<{nameof(MovementDefinitionFactory)}>.Instance.ApplyDefinitionToGameObject(\"{movementName.stringValue}\");");
|
||||
|
||||
if (quickPresetButtonPressed) LoadPresetQuick();
|
||||
if (longerPresetButtonPressed) LoadPresetLonger();
|
||||
|
@ -74,12 +75,12 @@ namespace Syntriax.Modules.Movement.Editor
|
|||
|
||||
movementDefinition.MovementConfigs = new MovementConfig[]
|
||||
{
|
||||
new MovementConfig(MovementFactory.GetTypeName(typeof(Implementations.GroundMovement1D)), 5f)
|
||||
new MovementConfig(typeof(Implementations.GroundMovement1D).FullName, 5f)
|
||||
};
|
||||
|
||||
movementDefinition.MonoBehaviours = new string[]
|
||||
{
|
||||
MovementFactory.GetTypeName(typeof(MovementController))
|
||||
typeof(MovementController).FullName
|
||||
};
|
||||
|
||||
UpdateSerializedObject();
|
||||
|
@ -91,14 +92,14 @@ namespace Syntriax.Modules.Movement.Editor
|
|||
|
||||
movementDefinition.MovementConfigs = new MovementConfig[]
|
||||
{
|
||||
new MovementConfig(MovementFactory.GetTypeName(typeof(Implementations.AirMovement1D)), 5f),
|
||||
new MovementConfig(MovementFactory.GetTypeName(typeof(Implementations.GroundMovement1D)), 5f)
|
||||
new MovementConfig(typeof(Implementations.AirMovement1D).FullName, 5f),
|
||||
new MovementConfig(typeof(Implementations.GroundMovement1D).FullName, 5f)
|
||||
};
|
||||
|
||||
movementDefinition.MonoBehaviours = new string[]
|
||||
{
|
||||
MovementFactory.GetTypeName(typeof(MovementController)),
|
||||
MovementFactory.GetTypeName(typeof(ToggleState.ToggleStateMonoBehaviour))
|
||||
typeof(MovementController).FullName,
|
||||
typeof(ToggleState.ToggleStateMonoBehaviour).FullName
|
||||
};
|
||||
|
||||
UpdateSerializedObject();
|
||||
|
|
Loading…
Reference in New Issue