Open Noxalus opened 3 years ago
I tried to use the ExecuteOnReloadAttribute
attribute instead, but same thing, it's working well on simple MonoBehaviour
, but the method is not called for generic classes 😢
Sorry I didn't see this! I believe I do have a version that adds support to generics, I will push that version soon. :)
I tried this too with a generic (latest code) and the static values marked with [ClearOnReload] only get cleared once, not once for every generic type that was instantiated. Any update on a fix?
@Noxalus I created a work-around for singletons, you can call this instead to manage whether a singleton for a certain type has been destroyed:
using TypeTable = System.Collections.Generic.Dictionary<System.Type, bool>;
// ---- Here is where you define your Singleton<T> generic class -----
static class SingletonHelper
{
[ClearOnReload] private static TypeTable destroyed = null;
public static bool IsDestroyed(System.Type t)
{
return destroyed != null && destroyed.ContainsKey(t);
}
public static void MarkDestroyed(System.Type t)
{
if (destroyed == null)
destroyed = new TypeTable();
destroyed[t] = true;
}
}
+1 Very need fix for this. Especially when working with singletons, because this solution is mainly needed for singletons.
@Watcher3056 I created a similar project that works for generics. https://github.com/stalomeow/QuickPlayMode
Hello!
Thank you for this project, it's much more handy that the one proposed by Unity!
I would like to use it to refresh my Singleton class, but it's a generic class and it seems it doesn't work for them.
Here it is:
I put some debug points in the
DomainReloadHandler
class and saw that it enters in thecatch
when calling thefield.SetValue
method for fields.Adding a trace for the exception message, I got this:
Do you know if there is a solution for this case?