protected virtual void Awake() { var idData = new EventActorComponentComputeID.Data(this); EventManager.TriggerEvent(new EventActorComponentComputeID(idData)); ID = idData.ID; #if UNITY_EDITOR if (!ID.IsValid) { Debug.Log("Apparently we could not get an actorID for a component, was there no factory?"); ActorFactory af = FindObjectOfType <ActorFactory>(); if (af != null) { ID = af.GetIDHackHackHack(this); } else { Debug.LogWarning("Oooh no! there is no ActorFactory in the scene!"); } } #endif }
private void Start() { var idData = new EventActorComponentComputeID.Data(this); EventManager.TriggerEvent(new EventActorComponentComputeID(idData)); ID = idData.ID; }
IActorComponent FindActorComponent(ActorID id) { IActorComponent actor = null; _usedActorIDs.TryGetValue(id.Value, out actor); return(actor); }
public ActorComponentRecord(ActorComponent component) { _type = component.GetType().Name; // _name = component.GetName(); _id = component.GetID(); // _parent = component.GetParentID(); // _parentName = component.GetParentName(); _data = component.GetData(); }
public void AddDependency(ActorID actorComponent, string url) { Dependencies.Add(new Dependency(actorComponent, url)); }
public Dependency(ActorID id, string url) { _id = id; _url = url; }
bool IsAnchorAsset(ActorID id) { return(id == AnchorAsset.GetID()); }
public void SetID(ActorID id) { ID = id; }
public override void PostLoad() { //Debug.Log("PostLoad " + name); if (_record == null) { Debug.LogWarning("PostLoad of Actor expected a non-null _record"); return; } //my parent in the unity scene hierarchy ActorID parentID = _record._parent; var data = new EventActorComponentFindFromID.Data(parentID); EventManager.TriggerEvent(new EventActorComponentFindFromID(data)); var parentComponent = data._foundActorComponent; if (parentComponent != null) { try { //Debug.Log("parenting " + name + " to " + parentComponent.GetName()); transform.SetParent(parentComponent.GetTransform()); } catch (Exception e) { Debug.LogException(e); } } //my world position var trans = _record._transform; if (trans.Position != null && trans.Position.Length == 3) { transform.position = new Vector3(trans.Position[0], trans.Position[1], trans.Position[2]); } else { transform.position = Vector3.zero; } if (trans.Rotation != null && trans.Rotation.Length == 4) { transform.rotation = new Quaternion(trans.Rotation[0], trans.Rotation[1], trans.Rotation[2], trans.Rotation[3]); } else { transform.rotation = Quaternion.identity; } //TODO local scale should be assigned after transform is parented if (trans.Scale != null && trans.Scale.Length == 3) { transform.localScale = new Vector3(trans.Scale[0], trans.Scale[1], trans.Scale[2]); } else { transform.localScale = Vector3.one; } //let any actorcomponents on this gameobject also do a postLoad var actorComponents = GetComponents <ActorComponent>(); foreach (var actorComponent in actorComponents) { if (actorComponent != this) { actorComponent.PostLoad(); } } }