[Add] Hot Reload

This commit is contained in:
2026-02-27 03:16:18 +07:00
parent 5067cb51a1
commit b37579153b
431 changed files with 43054 additions and 1 deletions
@@ -0,0 +1,57 @@
using UnityEditor;
namespace SingularityGroup.HotReload.Editor {
/// <summary>
/// An option stored inside the current Unity project.
/// </summary>
internal abstract class ProjectOptionBase : IOption, ISerializedProjectOption {
public abstract string ShortSummary { get; }
public abstract string Summary { get; }
public virtual bool GetValue(SerializedObject so) {
return so.FindProperty(ObjectPropertyName).boolValue;
}
protected SerializedProperty GetProperty(SerializedObject so) {
return so.FindProperty(ObjectPropertyName);
}
public virtual void SetValue(SerializedObject so, bool value) {
so.FindProperty(ObjectPropertyName).boolValue = value;
}
public virtual void InnerOnGUI(SerializedObject so) { }
public abstract string ObjectPropertyName { get; }
/// <remarks>
/// Override this if your option is not needed for on-device Hot Reload to work.<br/>
/// (by default, a project option must be true for Hot Reload to work)
/// </remarks>
public virtual bool IsRequiredForBuild() {
return true;
}
}
/// <summary>
/// An option that is stored on the user's computer (shared between Unity projects).
/// </summary>
internal abstract class ComputerOptionBase : IOption {
public abstract string ShortSummary { get; }
public abstract string Summary { get; }
public abstract bool GetValue();
/// Uses <see cref="HotReloadPrefs"/> for storing the value on the user's computer.
public virtual void SetValue(bool value) { }
public bool GetValue(SerializedObject so) => GetValue();
public virtual void SetValue(SerializedObject so, bool value) => SetValue(value);
void IOption.InnerOnGUI(SerializedObject so) {
InnerOnGUI();
}
public virtual void InnerOnGUI() { }
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dab8ef53c2ee30a40ab6a7e4abd1260c
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/Editor/Window/GUI/Options/Base/HotReloadOptionBase.cs
uploadId: 870414
@@ -0,0 +1,34 @@
using UnityEditor;
namespace SingularityGroup.HotReload.Editor {
public interface IOption {
string ShortSummary { get; }
string Summary { get; }
/// <param name="so">The <see cref="HotReloadSettingsObject"/> wrapped by SerializedObject</param>
bool GetValue(SerializedObject so);
/// <summary>
/// Handle the new value.
/// </summary>
/// <remarks>
/// Note: caller must skip calling this if value same as GetValue!
/// </remarks>
/// <param name="so">The <see cref="HotReloadSettingsObject"/> wrapped by SerializedObject</param>
/// <param name="value"></param>
void SetValue(SerializedObject so, bool value);
/// <param name="so">The <see cref="HotReloadSettingsObject"/> wrapped by SerializedObject</param>
void InnerOnGUI(SerializedObject so);
}
/// <summary>
/// An option scoped to the current Unity project.
/// </summary>
/// <remarks>
/// These options are intended to be shared with collaborators and used by Unity Player builds.
/// </remarks>
public interface ISerializedProjectOption {
string ObjectPropertyName { get; }
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0a626aa97160471f85de4646a634bdf1
timeCreated: 1674574633
AssetOrigin:
serializedVersion: 1
productId: 254358
packageName: Hot Reload | Edit Code Without Compiling
packageVersion: 1.13.17
assetPath: Packages/com.singularitygroup.hotreload/Editor/Window/GUI/Options/Base/OptionInterfaces.cs
uploadId: 870414