Movement Definition Creator Added

This commit is contained in:
2022-11-16 20:58:14 +03:00
parent 93793e1762
commit b6dbfea477
5 changed files with 106 additions and 64 deletions

View File

@@ -135,14 +135,5 @@ namespace Syntriax.Modules.Movement.Config
foreach (string monoBehaviours in definition.MonoBehaviours)
MovementFactory.Instance.AddToGameObject(gameObject, monoBehaviours);
}
#if UNITY_EDITOR
public static void SaveMovementDefinition(MovementDefinition definition)
{
string jsonText = JsonUtility.ToJson(definition, true);
string path = $"Assets/Resources/{ResourceDirectoryToDefinitions}{definition.Name}.json";
System.IO.File.WriteAllText(path, jsonText);
}
#endif
}
}

View File

@@ -67,17 +67,17 @@ namespace Syntriax.Modules.Movement.Config
public Component AddToGameObject(GameObject gameObject, string name)
{
if (!Types.ContainsKey(name))
throw new ArgumentException($"The key \"{ name }\" does not exists in the current { Name }");
throw new ArgumentException($"The key \"{name}\" does not exists in the current {Name}");
return gameObject.AddComponent(Types[name]);
}
public string GetTypeName(Type type)
public static string GetTypeName(Type type)
{
if (string.IsNullOrEmpty(type.Namespace))
return type.Name;
return $"{ type.Namespace }.{ type.Name }";
return $"{type.Namespace}.{type.Name}";
}
}
}