GameObject registry script
This commit is contained in:
parent
ed2e2c63ef
commit
2b2de1b52b
34
Client/Unity/GameObjectRegistry.cs
Normal file
34
Client/Unity/GameObjectRegistry.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class GameObjectRegistry : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public static GameObjectRegistry instance; //instance of gameobject registry in scene
|
||||||
|
public string uuid; //unique identifier for this client
|
||||||
|
public List<GameObject> gameObjects; //list to make it easy to register new gameobjects
|
||||||
|
public List<string> ids;
|
||||||
|
|
||||||
|
public Dictionary<string, GameObject> registry = new Dictionary<string, GameObject>(); //registry of game objects that can be synced (needs to be identical on both clients
|
||||||
|
public List<SyncData> registeredObjects = new List<SyncData>(); //game objcets that are currently being synced
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
GameObjectRegistry.instance = this;
|
||||||
|
|
||||||
|
uuid = System.Guid.NewGuid().ToString(); //create a uuid for this player
|
||||||
|
|
||||||
|
initializeRegistry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initializeRegistry()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
foreach (string id in ids)
|
||||||
|
{
|
||||||
|
registry.Add(id, gameObjects[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Client/Unity/GameObjectRegistry.cs.meta
Normal file
11
Client/Unity/GameObjectRegistry.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1c20e30fdef1b0841aa0fdb48748a6a6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: -20
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user