Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlong committed May 20, 2021
1 parent 11658d2 commit 79fb9b4
Show file tree
Hide file tree
Showing 48 changed files with 3,033 additions and 6 deletions.
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]in/
[Ll]ogs/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
Expand Down Expand Up @@ -38,7 +39,6 @@ ExportedObj/
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
Expand All @@ -57,4 +57,3 @@ sysinfo.txt

# Crashlytics generated file
crashlytics-build.properties

31 changes: 31 additions & 0 deletions HotProject/HotProject/HotUnity/HotScript.cs
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()
{
}
}
}
65 changes: 65 additions & 0 deletions HotProject/HotProject/HotUnity/HotScriptManager.cs
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);
}
}
}
13 changes: 13 additions & 0 deletions HotProject/HotProject/Test/Test.cs
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()
{
}
}
}
24 changes: 24 additions & 0 deletions HotProject/HotProject/Test/Test2.cs
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 added HotProject/HotProject/libs/UnityEngine.UI.dll
Binary file not shown.
Binary file added HotProject/HotProject/libs/UnityEngine.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions UnityProject/.vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
8 changes: 8 additions & 0 deletions UnityProject/Assets/HotUnity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions UnityProject/Assets/HotUnity/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79fb9b4

Please sign in to comment.