game version overlay, working on actors sync

This commit is contained in:
2025-07-16 23:03:48 +02:00
parent 0da6f275c0
commit 4ec3dedd42
31 changed files with 1826 additions and 680 deletions

View 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;
}
}
}
}
}