generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing some issues with preview system invalidations not working (#265)
* feat: add support for explicit change notification * fix: issues with preview system invalidations not chaining properly Note that the GC fixes are a temporary hack - this API is too error-prone and needs revisiting.
- Loading branch information
1 parent
4192eca
commit c9de8c4
Showing
5 changed files
with
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#region | ||
|
||
using JetBrains.Annotations; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
#endregion | ||
|
||
namespace nadena.dev.ndmf.rq.unity.editor | ||
{ | ||
public static class ChangeNotifier | ||
{ | ||
/// <summary> | ||
/// Notifies the reactive query and NDMF preview system of a change in an object that isn't tracked by the normal | ||
/// unity ObjectchangeEventStream system. | ||
/// </summary> | ||
/// <param name="obj"></param> | ||
public static void NotifyObjectUpdate(Object obj) | ||
{ | ||
if (obj != null) ObjectWatcher.Instance.Hierarchy.InvalidateTree(obj.GetInstanceID()); | ||
} | ||
|
||
/// <summary> | ||
/// Notifies the reactive query and NDMF preview system of a change in an object that isn't tracked by the normal | ||
/// unity ObjectchangeEventStream system. | ||
/// </summary> | ||
/// <param name="obj"></param> | ||
public static void NotifyObjectUpdate(int instanceId) | ||
{ | ||
ObjectWatcher.Instance.Hierarchy.InvalidateTree(instanceId); | ||
} | ||
|
||
private class Processor : AssetPostprocessor | ||
{ | ||
[UsedImplicitly] | ||
static void OnPostprocessAllAssets( | ||
// ReSharper disable once Unity.IncorrectMethodSignature | ||
string[] importedAssets, | ||
// ReSharper disable once UnusedParameter.Local | ||
string[] deletedAssets, | ||
// ReSharper disable once UnusedParameter.Local | ||
string[] movedAssets, | ||
// ReSharper disable once UnusedParameter.Local | ||
string[] movedFromAssetPaths, | ||
// ReSharper disable once UnusedParameter.Local | ||
bool didDomainReload | ||
) | ||
{ | ||
foreach (var asset in importedAssets) | ||
{ | ||
var subassets = AssetDatabase.LoadAllAssetsAtPath(asset); | ||
foreach (var subasset in subassets) | ||
{ | ||
NotifyObjectUpdate(subasset); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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