game version overlay, working on actors sync
This commit is contained in:
34
Editor/Background/EnsureUniqueActorID.cs
Normal file
34
Editor/Background/EnsureUniqueActorID.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Editor.Background {
|
||||
[InitializeOnLoad]
|
||||
public class EnsureUniqueActorID {
|
||||
static EnsureUniqueActorID() {
|
||||
ObjectChangeEvents.changesPublished += OnObjectChange;
|
||||
}
|
||||
|
||||
static void OnObjectChange(ref ObjectChangeEventStream stream) {
|
||||
|
||||
for (int i = 0; i < stream.length; ++i) {
|
||||
switch (stream.GetEventType(i)) {
|
||||
case ObjectChangeKind.CreateGameObjectHierarchy:
|
||||
stream.GetCreateGameObjectHierarchyEvent(i, out CreateGameObjectHierarchyEventArgs createEvent);
|
||||
|
||||
GameObject gameObjectChanged =
|
||||
EditorUtility.InstanceIDToObject(createEvent.instanceId) as GameObject;
|
||||
|
||||
if (gameObjectChanged != null && gameObjectChanged.TryGetComponent(out Actor actor)) {
|
||||
actor.ActorID = UniqueID.NewULongFromGuid();
|
||||
EditorUtility.SetDirty(actor);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Background/EnsureUniqueActorID.cs.meta
Normal file
3
Editor/Background/EnsureUniqueActorID.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bccf1b1891f9486e85330d8c7be3ea52
|
||||
timeCreated: 1752350253
|
||||
Reference in New Issue
Block a user