forked from psygames/HotUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yinlong
committed
May 20, 2021
1 parent
11658d2
commit 79fb9b4
Showing
48 changed files
with
3,033 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using UnityEngine; | ||
|
||
namespace HotProject | ||
{ | ||
public class HotScript | ||
{ | ||
public GameObject gameObject { get; } | ||
public string name { get; set; } | ||
|
||
public virtual void Awake() | ||
{ | ||
|
||
} | ||
|
||
public virtual void Start() | ||
{ | ||
} | ||
|
||
public virtual void Update() | ||
{ | ||
} | ||
|
||
public virtual void OnGUI() | ||
{ | ||
} | ||
|
||
public virtual void OnDestroy() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace HotProject | ||
{ | ||
public class HotScriptManager | ||
{ | ||
private static HotScriptManager _ins = null; | ||
private static HotScriptManager ins | ||
{ | ||
get | ||
{ | ||
if (_ins == null) | ||
{ | ||
_ins = new HotScriptManager(); | ||
} | ||
return _ins; | ||
} | ||
} | ||
|
||
private Dictionary<HotScriptAdapter, HotScript> hotScripts = new Dictionary<HotScriptAdapter, HotScript>(); | ||
|
||
public static void Awake(HotScriptAdapter adapter) | ||
{ | ||
Type scriptType = Type.GetType(adapter.targetClass); | ||
HotScript behaviour = (HotScript)Activator.CreateInstance(scriptType); | ||
foreach (var info in adapter.cacheInfos) | ||
{ | ||
var field = scriptType.GetField(info.fieldName); | ||
if (typeof(HotScript).IsAssignableFrom(field.FieldType)) | ||
{ | ||
field.SetValue(behaviour, ((HotScriptAdapter)info.value).targetObj); | ||
} | ||
else | ||
{ | ||
field.SetValue(behaviour, info.value); | ||
} | ||
} | ||
adapter.targetObj = behaviour; | ||
ins.hotScripts.Add(adapter, behaviour); | ||
behaviour.Awake(); | ||
} | ||
|
||
public static void Start(HotScriptAdapter adapter) | ||
{ | ||
ins.hotScripts[adapter].Start(); | ||
} | ||
|
||
public static void Update(HotScriptAdapter adapter) | ||
{ | ||
ins.hotScripts[adapter].Update(); | ||
} | ||
|
||
public static void OnGUI(HotScriptAdapter adapter) | ||
{ | ||
ins.hotScripts[adapter].OnGUI(); | ||
} | ||
|
||
public static void OnDestroy(HotScriptAdapter adapter) | ||
{ | ||
ins.hotScripts[adapter].OnDestroy(); | ||
ins.hotScripts.Remove(adapter); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using UnityEngine; | ||
|
||
namespace HotProject | ||
{ | ||
public class Test : HotScript | ||
{ | ||
public string testText; | ||
public Vector3 testVec3; | ||
public override void Awake() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace HotProject | ||
{ | ||
public class Test2 : HotScript | ||
{ | ||
public Test test; | ||
public string test2Text; | ||
public Image image; | ||
public Button button; | ||
|
||
public override void Awake() | ||
{ | ||
button.onClick.AddListener(() => | ||
{ | ||
Debug.Log(test.testText); | ||
Debug.Log(test.testVec3); | ||
Debug.Log(test2Text); | ||
image.color = Random.ColorHSV(); | ||
}); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"version": "1.0", | ||
"components": [ | ||
"Microsoft.VisualStudio.Workload.ManagedGame" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.