From f25a9b676b0ff7cab3eb15e951472121637f78fa Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Nov 2022 14:01:01 +0300 Subject: [PATCH] Editor Updated & Cleanup --- Config/MovementFactory.cs | 10 +--------- Editor/DefinitionCreatorEditor.cs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Config/MovementFactory.cs b/Config/MovementFactory.cs index be1ce46..8e94ccd 100644 --- a/Config/MovementFactory.cs +++ b/Config/MovementFactory.cs @@ -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}"; - } } } diff --git a/Editor/DefinitionCreatorEditor.cs b/Editor/DefinitionCreatorEditor.cs index 8c4c8be..6238c2a 100644 --- a/Editor/DefinitionCreatorEditor.cs +++ b/Editor/DefinitionCreatorEditor.cs @@ -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)}<{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();