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.
* feat: preview framework Import the preview framework from NDMF-Core (bdunderscore/ndmf-core@7af1614) * feat: NDMF build pipeline integration for preview system * chore: improve API docs * chore: remove some spammy debug logs * chore: adjustments to public API scope * chore: CHANGELOG updates * fix: invalidate all watchers when the scene changes * chore: suppress spurious warnings * chore: add 0Harmony.dll for standalone configurations * fix: scene header shows as "deleted object" in some cases
- Loading branch information
1 parent
d48dd39
commit 64e0b51
Showing
114 changed files
with
7,587 additions
and
2 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
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Andreas Pardeike | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
#region | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using UnityEditor; | ||
using UnityEngine.Profiling; | ||
using Debug = UnityEngine.Debug; | ||
|
||
#endregion | ||
|
||
namespace nadena.dev.ndmf.rq.unity.editor | ||
{ | ||
internal class ChangeStreamMonitor | ||
{ | ||
[InitializeOnLoadMethod] | ||
static void Init() | ||
{ | ||
ObjectChangeEvents.changesPublished += OnChange; | ||
} | ||
|
||
private static void OnChange(ref ObjectChangeEventStream stream) | ||
{ | ||
Profiler.BeginSample("ChangeStreamMonitor.OnChange"); | ||
|
||
int length = stream.length; | ||
for (int i = 0; i < length; i++) | ||
{ | ||
try | ||
{ | ||
HandleEvent(stream, i); | ||
} | ||
catch (Exception e) | ||
{ | ||
Debug.LogError($"Error handling event {i}: {e}"); | ||
} | ||
} | ||
|
||
Profiler.EndSample(); | ||
} | ||
|
||
private static void HandleEvent(ObjectChangeEventStream stream, int i) | ||
{ | ||
switch (stream.GetEventType(i)) | ||
{ | ||
case ObjectChangeKind.None: break; | ||
|
||
case ObjectChangeKind.ChangeScene: | ||
{ | ||
ObjectWatcher.Instance.Hierarchy.InvalidateAll(); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.CreateGameObjectHierarchy: | ||
{ | ||
stream.GetCreateGameObjectHierarchyEvent(i, out var data); | ||
|
||
ObjectWatcher.Instance.Hierarchy.FireGameObjectCreate(data.instanceId); | ||
break; | ||
} | ||
|
||
case ObjectChangeKind.ChangeGameObjectStructureHierarchy: | ||
{ | ||
stream.GetChangeGameObjectStructureHierarchyEvent(i, out var data); | ||
|
||
OnChangeGameObjectStructureHierarchy(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.ChangeGameObjectStructure: // add/remove components | ||
{ | ||
stream.GetChangeGameObjectStructureEvent(i, out var data); | ||
OnChangeGameObjectStructure(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.ChangeGameObjectParent: | ||
{ | ||
stream.GetChangeGameObjectParentEvent(i, out var data); | ||
OnChangeGameObjectParent(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.ChangeGameObjectOrComponentProperties: | ||
{ | ||
stream.GetChangeGameObjectOrComponentPropertiesEvent(i, out var data); | ||
OnChangeGameObjectOrComponentProperties(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.DestroyGameObjectHierarchy: | ||
{ | ||
stream.GetDestroyGameObjectHierarchyEvent(i, out var data); | ||
OnDestroyGameObjectHierarchy(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.CreateAssetObject: break; | ||
case ObjectChangeKind.DestroyAssetObject: | ||
{ | ||
stream.GetDestroyAssetObjectEvent(i, out var data); | ||
OnDestroyAssetObject(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.ChangeAssetObjectProperties: | ||
{ | ||
stream.GetChangeAssetObjectPropertiesEvent(i, out var data); | ||
OnChangeAssetObjectProperties(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.UpdatePrefabInstances: | ||
{ | ||
stream.GetUpdatePrefabInstancesEvent(i, out var data); | ||
OnUpdatePrefabInstances(data); | ||
|
||
break; | ||
} | ||
|
||
case ObjectChangeKind.ChangeChildrenOrder: | ||
{ | ||
stream.GetChangeChildrenOrderEvent(i, out var data); | ||
OnChangeChildrenOrder(data); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
|
||
private static void OnChangeChildrenOrder(ChangeChildrenOrderEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.FireReorderNotification(instanceId); | ||
} | ||
|
||
private static void OnUpdatePrefabInstances(UpdatePrefabInstancesEventArgs data) | ||
{ | ||
foreach (var iid in data.instanceIds) | ||
{ | ||
ObjectWatcher.Instance.Hierarchy.InvalidateTree(iid); | ||
} | ||
} | ||
|
||
private static void OnChangeAssetObjectProperties(ChangeAssetObjectPropertiesEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.FireObjectChangeNotification(instanceId); | ||
} | ||
|
||
private static void OnDestroyAssetObject(DestroyAssetObjectEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.InvalidateTree(instanceId); | ||
} | ||
|
||
private static void OnDestroyGameObjectHierarchy(DestroyGameObjectHierarchyEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.InvalidateTree(instanceId); | ||
} | ||
|
||
private static void OnChangeGameObjectOrComponentProperties(ChangeGameObjectOrComponentPropertiesEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.FireObjectChangeNotification(instanceId); | ||
} | ||
|
||
private static void OnChangeGameObjectParent(ChangeGameObjectParentEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
var priorParentId = data.previousParentInstanceId; | ||
var newParentId = data.newParentInstanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.FireReparentNotification(instanceId); | ||
} | ||
|
||
private static void OnChangeGameObjectStructure(ChangeGameObjectStructureEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.FireStructureChangeEvent(instanceId); | ||
} | ||
|
||
private static void OnChangeGameObjectStructureHierarchy(ChangeGameObjectStructureHierarchyEventArgs data) | ||
{ | ||
var instanceId = data.instanceId; | ||
|
||
ObjectWatcher.Instance.Hierarchy.InvalidateTree(instanceId); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.