[Add] Hot Reload
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c895e9065d763824f9211fa8054f7c2e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1079
File diff suppressed because it is too large
Load Diff
+14
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae744488364b34fcf8c80218eadc721c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 254358
|
||||
packageName: Hot Reload | Edit Code Without Compiling
|
||||
packageVersion: 1.13.17
|
||||
assetPath: Packages/com.singularitygroup.hotreload/Runtime/Demo/Scenes/HotReloadBasicDemo.unity
|
||||
uploadId: 870414
|
||||
+9607
File diff suppressed because it is too large
Load Diff
+14
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fad9aa54ab3335844b5a35b9eb6ae286
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 254358
|
||||
packageName: Hot Reload | Edit Code Without Compiling
|
||||
packageVersion: 1.13.17
|
||||
assetPath: Packages/com.singularitygroup.hotreload/Runtime/Demo/Scenes/HotReloadBurstDemo.unity
|
||||
uploadId: 870414
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: HotReloadBurstDemoSettings
|
||||
serializedVersion: 6
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 1
|
||||
m_BakeBackend: 1
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 3
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 2
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_PVRTiledBaking: 0
|
||||
m_NumRaysToShootPerTexel: -1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 961e97ae3d4011b47a1198a930f5c30d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 254358
|
||||
packageName: Hot Reload | Edit Code Without Compiling
|
||||
packageVersion: 1.13.17
|
||||
assetPath: Packages/com.singularitygroup.hotreload/Runtime/Demo/Scenes/HotReloadBurstDemoSettings.lighting
|
||||
uploadId: 870414
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30c72b28fb747184ba79468d3571dea4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,217 @@
|
||||
#if ENABLE_MONO && (DEVELOPMENT_BUILD || UNITY_EDITOR)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SingularityGroup.HotReload.Demo {
|
||||
class HotReloadBasicDemo : MonoBehaviour {
|
||||
|
||||
public GameObject cube;
|
||||
public Text informationText;
|
||||
public Button openWindowButton;
|
||||
public Button openScriptButton;
|
||||
public TextAsset thisScript;
|
||||
|
||||
// // 1. Adding fields (Added fields can show in the inspector)
|
||||
// public int myNewField = 1;
|
||||
|
||||
void Start() {
|
||||
if (Application.isEditor) {
|
||||
openWindowButton.onClick.AddListener(Demo.I.OpenHotReloadWindow);
|
||||
openScriptButton.onClick.AddListener(() => Demo.I.OpenScriptFile(thisScript, myStaticField, 13));
|
||||
} else {
|
||||
openWindowButton.gameObject.SetActive(false);
|
||||
openScriptButton.gameObject.SetActive(false);
|
||||
informationText.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
if (Demo.I.IsServerRunning()) {
|
||||
informationText.text = Localization.Translations.Common.HotReloadIsRunning;
|
||||
} else {
|
||||
informationText.text = Localization.Translations.Common.HotReloadIsNotRunning;
|
||||
}
|
||||
|
||||
// // 2. Editing functions in monobehaviours, normal classes or static classes
|
||||
// // Edit the vector to rotate the cube in the scene differently or change the speed
|
||||
// var speed = 100;
|
||||
// cube.transform.Rotate(new Vector3(0, 1, 0) * Time.deltaTime * speed);
|
||||
|
||||
// // 2. Editing functions in monobehaviours, normal classes or static classes
|
||||
// // Uncomment this code to scale the cube
|
||||
// cube.transform.localScale = Mathf.Sin(Time.time) * Vector3.one;
|
||||
|
||||
// // 2. Editing functions in monobehaviours, normal classes or static classes
|
||||
// // Uncomment this code to make the cube move from left to right and back
|
||||
// var newPos = cube.transform.position += (cube.transform.localScale.x < 0.5 ? Vector3.left : Vector3.right) * Time.deltaTime;
|
||||
// if(Mathf.Abs(newPos.x) > 10) {
|
||||
// cube.transform.position = Vector3.zero;
|
||||
// }
|
||||
}
|
||||
|
||||
// 3. Editing lambda methods
|
||||
static Func<int, int> addFunction = x => {
|
||||
var result = x + 10;
|
||||
Debug.Log("Add: " + result);
|
||||
// // uncomment to change the operator to multiply and log the result
|
||||
// result = x * 10;
|
||||
// Debug.Log("Multiply: " + result);
|
||||
return result;
|
||||
};
|
||||
|
||||
// 4. Editing async/await methods
|
||||
async Task AsyncMethod() {
|
||||
// await Task.Delay(500);
|
||||
// Debug.Log("AsyncMethod");
|
||||
|
||||
// // silicense warning
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
// 5. Editing properties (get/set)
|
||||
public static string SomeString {
|
||||
// edit the get method
|
||||
get {
|
||||
var someStringHere = "This is some string";
|
||||
return someStringHere;
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Editing indexers (square bracket access such as dictionaries)
|
||||
class CustomDictionary : Dictionary<string, int> {
|
||||
public new int this[string key] {
|
||||
get {
|
||||
// // uncomment to change the indexer and log a different entry based on case
|
||||
// return base[key.ToLower()];
|
||||
return base[key.ToUpper()];
|
||||
}
|
||||
set {
|
||||
base[key.ToUpper()] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
CustomDictionary randomDict = new CustomDictionary {
|
||||
{ "a", 4 },
|
||||
{ "A", 5 },
|
||||
{ "b", 9 },
|
||||
{ "B", 10 },
|
||||
{ "c", 14 },
|
||||
{ "C", 15 },
|
||||
{ "d", 19 },
|
||||
{ "D", 20 }
|
||||
};
|
||||
|
||||
// 7. Editing operators methods (explicit and implicit operators)
|
||||
public class Email {
|
||||
public string Value { get; }
|
||||
|
||||
public Email(string value) {
|
||||
Value = value;
|
||||
}
|
||||
|
||||
// Define implicit operator
|
||||
public static implicit operator string(Email value)
|
||||
// Uncomment to change the implicit operator
|
||||
// => value.Value + " FOO";
|
||||
=> value.Value;
|
||||
|
||||
// // Uncomment to change add an implicit operator
|
||||
// public static implicit operator byte[](Email value)
|
||||
// => Encoding.UTF8.GetBytes(value.Value);
|
||||
|
||||
// Define explicit operator
|
||||
public static explicit operator Email(string value)
|
||||
=> new Email(value);
|
||||
}
|
||||
|
||||
// 8. Editing fields: modifiers/type/name/initializer
|
||||
public int myEditedField = 4;
|
||||
|
||||
// 9. Editing static field initializers (variable value is updated)
|
||||
static readonly int myStaticField = 31;
|
||||
|
||||
// // 10. Adding auto properties/events
|
||||
// int MyProperty { get; set; } = 6;
|
||||
// event Action MyEvent = () => Debug.Log("MyEvent");
|
||||
|
||||
class GenericClass<T> {
|
||||
// // 11. Adding methods in generic classes
|
||||
// public void GenericMethod() {
|
||||
// Debug.Log("GenericMethod");
|
||||
// }
|
||||
// // 12. Adding fields (any type) in generic classes
|
||||
// public T myGenericField;
|
||||
}
|
||||
|
||||
void LateUpdate() {
|
||||
// // 3. Editing lambda methods
|
||||
// addFunction(10);
|
||||
|
||||
|
||||
// // 4. Editing async/await methods
|
||||
// AsyncMethod().Forget();
|
||||
|
||||
|
||||
// // 5. Editing properties (get/set)
|
||||
// Debug.Log(SomeString);
|
||||
|
||||
|
||||
// // 6. Editing indexers (square bracket access such as dictionaries)
|
||||
// Debug.Log(randomDict["A"]);
|
||||
|
||||
|
||||
// // 7. Editing operators methods (explicit and implicit operators)
|
||||
Email email = new Email("example@example.com");
|
||||
// string stringEmail = email;
|
||||
// Debug.Log(stringEmail);
|
||||
|
||||
// // Uncomment new operator in Email class + Uncomment this to add byte implicit operator
|
||||
// byte[] byteEmail = email;
|
||||
// var hexRepresentation = BitConverter.ToString(byteEmail);
|
||||
// Debug.Log(hexRepresentation);
|
||||
// Debug.Log(Encoding.UTF8.GetString(byteEmail));
|
||||
|
||||
// // 8. Editing fields: modifiers/type/name/initializer
|
||||
// Debug.Log("myEditedField: " + myEditedField);
|
||||
|
||||
// // 9. Editing static field initializers (variable value is updated)
|
||||
// Debug.Log("myStaticField: " + myStaticField);
|
||||
|
||||
// // 10. Adding auto properties/events
|
||||
// Debug.Log("MyProperty: " + MyProperty);
|
||||
// MyEvent.Invoke();
|
||||
|
||||
// var newClass = new GenericClass<int>();
|
||||
// // 11. Adding methods in generic classes
|
||||
// newClass.GenericMethod();
|
||||
// // 12. Adding fields in generic classes
|
||||
// newClass.myGenericField = 3;
|
||||
// Debug.Log("myGenericField: " + newClass.myGenericField);
|
||||
|
||||
// // 13. Editing lambda methods with closures
|
||||
// // Uncomment to log sorted array
|
||||
// // Switch a and b to reverse the sorting
|
||||
// int[] numbers = { 5, 3, 8, 1, 9 };
|
||||
// Array.Sort(numbers, (b, a) => a.CompareTo(b));
|
||||
// Debug.Log(string.Join(", ", numbers));
|
||||
}
|
||||
|
||||
// This function gets invoked every time it's patched
|
||||
[InvokeOnHotReloadLocal]
|
||||
static void OnHotReloadMe() {
|
||||
// // change the string to see the method getting invoked
|
||||
// Debug.Log("Hello there");
|
||||
}
|
||||
|
||||
// // 14. Adding event functions
|
||||
// void OnDisable() {
|
||||
// Debug.Log("OnDisable");
|
||||
// }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a2e4d3f095a9441688c70278068eee0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 254358
|
||||
packageName: Hot Reload | Edit Code Without Compiling
|
||||
packageVersion: 1.13.17
|
||||
assetPath: Packages/com.singularitygroup.hotreload/Runtime/Demo/Scripts/HotReloadBasicDemo.cs
|
||||
uploadId: 870414
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#if ENABLE_MONO && (DEVELOPMENT_BUILD || UNITY_EDITOR)
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Jobs;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SingularityGroup.HotReload.Demo {
|
||||
public class HotReloadBurstJobsDemo : MonoBehaviour {
|
||||
public Transform[] cubes;
|
||||
public Text informationText;
|
||||
public Button openWindowButton;
|
||||
public Button openScriptButton;
|
||||
public TextAsset thisScript;
|
||||
|
||||
TransformAccessArray cubeTransforms;
|
||||
CubeJob job;
|
||||
void Awake() {
|
||||
cubeTransforms = new TransformAccessArray(cubes);
|
||||
if(Application.isEditor) {
|
||||
openWindowButton.onClick.AddListener(Demo.I.OpenHotReloadWindow);
|
||||
openScriptButton.onClick.AddListener(() => Demo.I.OpenScriptFile(thisScript, 49, 17));
|
||||
} else {
|
||||
openWindowButton.gameObject.SetActive(false);
|
||||
openScriptButton.gameObject.SetActive(false);
|
||||
}
|
||||
informationText.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
job.deltaTime = Time.deltaTime;
|
||||
job.time = Time.time;
|
||||
var handle = job.Schedule(cubeTransforms);
|
||||
handle.Complete();
|
||||
|
||||
if (Demo.I.IsServerRunning()) {
|
||||
informationText.text = Localization.Translations.Common.HotReloadIsRunning;
|
||||
} else {
|
||||
informationText.text = Localization.Translations.Common.HotReloadIsNotRunning;
|
||||
}
|
||||
}
|
||||
|
||||
struct CubeJob : IJobParallelForTransform {
|
||||
public float deltaTime;
|
||||
public float time;
|
||||
public void Execute(int index, TransformAccess transform) {
|
||||
transform.localRotation *= Quaternion.Euler(50 * deltaTime, 0, 0);
|
||||
|
||||
// Uncomment this code to scale the cubes
|
||||
// var scale = Mathf.Abs(Mathf.Sin(time));
|
||||
// transform.localScale = new Vector3(scale, scale, scale);
|
||||
|
||||
// Uncomment this code to make the cube move from left to right and back
|
||||
// transform.position += (transform.localScale.x < 0.5 ? Vector3.left : Vector3.right) * deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
cubeTransforms.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e09948cf1f317d04fbaf410dbfe91656
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 254358
|
||||
packageName: Hot Reload | Edit Code Without Compiling
|
||||
packageVersion: 1.13.17
|
||||
assetPath: Packages/com.singularitygroup.hotreload/Runtime/Demo/Scripts/HotReloadBurstJobsDemo.cs
|
||||
uploadId: 870414
|
||||
@@ -0,0 +1,29 @@
|
||||
#if ENABLE_MONO && (DEVELOPMENT_BUILD || UNITY_EDITOR)
|
||||
using UnityEngine;
|
||||
|
||||
namespace SingularityGroup.HotReload.Demo {
|
||||
public interface IDemo {
|
||||
bool IsServerRunning();
|
||||
void OpenHotReloadWindow();
|
||||
void OpenScriptFile(TextAsset textAsset, int line, int column);
|
||||
}
|
||||
|
||||
public static class Demo {
|
||||
public static IDemo I = new PlayerDemo();
|
||||
}
|
||||
|
||||
public class PlayerDemo : IDemo {
|
||||
public bool IsServerRunning() {
|
||||
return ServerHealthCheck.I.IsServerHealthy;
|
||||
}
|
||||
|
||||
public void OpenHotReloadWindow() {
|
||||
//no-op
|
||||
}
|
||||
|
||||
public void OpenScriptFile(TextAsset textAsset, int line, int column) {
|
||||
//no-op
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04dccdcced0245f1830021fdcad1d28a
|
||||
timeCreated: 1677321944
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 254358
|
||||
packageName: Hot Reload | Edit Code Without Compiling
|
||||
packageVersion: 1.13.17
|
||||
assetPath: Packages/com.singularitygroup.hotreload/Runtime/Demo/Scripts/IDemo.cs
|
||||
uploadId: 870414
|
||||
Reference in New Issue
Block a user