Ejemplo n.º 1
0
        internal static GameObject CreateGameObject(Actor actor)
        {
            ActorProxy actorProxy    = null;
            GameObject unityInstance = null;
            GameObject unityPrefab   = GlobalSettings.PrefabLocator(actor);

            if (unityPrefab == null)
            {
                log.Error("Could not load unity prefab for {0}", actor);
                return(null);
            }

            unityInstance = (GameObject)GameObject.Instantiate(unityPrefab);
            actorProxy    = unityInstance.AddComponent <ActorProxy>();

            log.Info("Instantiated game object {0}", unityInstance);

            // Store actor
            actorProxy.Actor = actor;

            // Register actor with gameobject so we have a link that goes both ways
            GameObjectMap.Register(actor, unityInstance);

            // Return game object
            return(unityInstance);
        }
Ejemplo n.º 2
0
        public override void BeforeActorStart(Actor actor)
        {
            PeerUtils.CreateGameObject(actor);

            GameObject go = GameObjectMap.Retrieve(actor);

            go.transform.position = Converter.Convert(actor.Transform.Position);
            go.transform.rotation = Converter.Convert(actor.Transform.Rotation);
        }
Ejemplo n.º 3
0
 public override void BeforeActorDestroy(Actor actor)
 {
     GameObject.Destroy(actor.GetGameObject());
     GameObjectMap.Remove(actor);
 }
Ejemplo n.º 4
0
 public static GameObject GetGameObject(this Behaviour behaviour)
 {
     return(GameObjectMap.Retrieve(behaviour.Actor));
 }
Ejemplo n.º 5
0
 public static UnityEngine.Transform GetUnityTransform(this Actor actor)
 {
     return(GameObjectMap.Retrieve(actor).transform);
 }
Ejemplo n.º 6
0
 public static GameObject GetGameObject(this Actor actor)
 {
     return(GameObjectMap.Retrieve(actor));
 }