Esempio n. 1
0
        private static PropAbstractBehaviour InstantiatePropBehaviour(PropAbstractBehaviour input)
        {
            GameObject expr_0B = UnityEngine.Object.Instantiate <GameObject>(input.gameObject);

            expr_0B.transform.localScale = Vector3.one;
            return(expr_0B.GetComponent <PropAbstractBehaviour>());
        }
Esempio n. 2
0
 public bool TryGetPropBehaviour(Prop prop, out PropAbstractBehaviour behaviour)
 {
     if (this.mActivePropBehaviours.ContainsKey(prop.ID))
     {
         behaviour = this.mActivePropBehaviours[prop.ID];
         return(true);
     }
     behaviour = null;
     return(false);
 }
Esempio n. 3
0
        public PropAbstractBehaviour AssociateProp(PropAbstractBehaviour templateBehaviour, Prop newProp)
        {
            if (this.mActivePropBehaviours.ContainsKey(newProp.ID))
            {
                Debug.LogWarning("Prop has already an associated behaviour");
                return(null);
            }
            StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl;

            if (templateBehaviour != null)
            {
                if (templateBehaviour.transform.parent == base.transform)
                {
                    PropAbstractBehaviour propAbstractBehaviour = ReconstructionAbstractBehaviour.InstantiatePropBehaviour(templateBehaviour);
                    Transform             transform             = null;
                    if (newProp.Parent == null)
                    {
                        transform = base.transform;
                    }
                    else if (newProp.Parent is Surface)
                    {
                        if (this.mActiveSurfaceBehaviours.ContainsKey(newProp.Parent.ID))
                        {
                            transform = this.mActiveSurfaceBehaviours[newProp.Parent.ID].transform;
                        }
                        else
                        {
                            Debug.LogError("Parent Surface with id " + newProp.Parent.ID + " could not be found");
                        }
                    }
                    else if (newProp.Parent is Prop)
                    {
                        if (this.mActivePropBehaviours.ContainsKey(newProp.Parent.ID))
                        {
                            transform = this.mActivePropBehaviours[newProp.Parent.ID].transform;
                        }
                        else
                        {
                            Debug.LogError("Parent Prop with id " + newProp.Parent.ID + " could not be found");
                        }
                    }
                    if (transform != null)
                    {
                        propAbstractBehaviour.transform.parent = transform;
                    }
                    propAbstractBehaviour.gameObject.SetActive(true);
                    this.AssociatePropBehaviour(newProp, propAbstractBehaviour);
                    this.mActivePropBehaviours.Add(newProp.ID, propAbstractBehaviour);
                    stateManagerImpl.RegisterExternallyManagedTrackableBehaviour(propAbstractBehaviour);
                    return(propAbstractBehaviour);
                }
                Debug.LogError("ReconstructionBehaviour.AssociateProp: provided template needs to be a child of the Reconstruction object.");
            }
            return(null);
        }
Esempio n. 4
0
        private void UnregisterDeletedProps(List <Prop> deletedProps)
        {
            StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl;

            foreach (Prop current in deletedProps)
            {
                if (this.mActivePropBehaviours.ContainsKey(current.ID))
                {
                    PropAbstractBehaviour propAbstractBehaviour = this.mActivePropBehaviours[current.ID];
                    if (propAbstractBehaviour != null)
                    {
                        propAbstractBehaviour.OnTrackerUpdate(TrackableBehaviour.Status.NOT_FOUND);
                        propAbstractBehaviour.UnregisterTrackable();
                        UnityEngine.Object.Destroy(propAbstractBehaviour.gameObject);
                    }
                    this.mActivePropBehaviours.Remove(current.ID);
                    stateManagerImpl.UnregisterExternallyManagedTrackableBehaviour(current.ID);
                }
            }
        }
Esempio n. 5
0
 private void AssociatePropBehaviour(Prop trackable, PropAbstractBehaviour behaviour)
 {
     behaviour.InitializeProp(trackable);
 }