Skip to content
Snippets Groups Projects
Commit e9bc7f52 authored by Samuel Truman's avatar Samuel Truman
Browse files

Refactoring

parent 2347ade4
No related branches found
No related tags found
No related merge requests found
using de.jmu.ge.viavr.UnityBridge.Core;
using UnityEngine;
public class AnotherExamplePackage : Package {
public class AnotherExamplePackageConfigurator : PackageConfigurator {
public override void Init() {
Debug.Log(new AnotherMathTest().Subtract(3, 2));
}
......
namespace de.jmu.ge.viavr.UnityBridge.Core {
public abstract class Package {
public abstract class PackageConfigurator {
// TODO:
/// <summary>
///
......
......@@ -12,7 +12,7 @@ public static void ExecuteAll() {
}
[MenuItem("Test/Init")] // TODO: remove line
public static void Init() => CallMethods(nameof(Package.Init));
public static void Init() => CallMethods(nameof(PackageConfigurator.Init));
[MenuItem("Test/Configure Scenes")] // TODO: remove line
public static void OnConfigureScene() {
......@@ -20,18 +20,18 @@ public static void OnConfigureScene() {
foreach(var guid in guids) {
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
EditorSceneManager.OpenScene(assetPath);
CallMethods(nameof(Package.OnConfigureScene));
CallMethods(nameof(PackageConfigurator.OnConfigureScene));
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
}
}
public static void OnPostConfiguration() => CallMethods(nameof(Package.OnPostConfiguration));
public static void OnPostConfiguration() => CallMethods(nameof(PackageConfigurator.OnPostConfiguration));
private static void CallMethods(string methodName) {
AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(t => t.IsSubclassOf(typeof(Package)))
.Where(t => t.IsSubclassOf(typeof(PackageConfigurator)))
.ToList()
.ForEach(subclass => {
var instance = Activator.CreateInstance(subclass);
......
using UnityEngine;
namespace de.jmu.ge.viavr.UnityBridge.Core {
public class ExamplePackage: Package {
public class ExamplePackageConfigurator: PackageConfigurator {
public override void Init() {
Debug.Log("Init");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment