Ejemplo n.º 1
0
 virtual protected void OnCreatedInEditor()
 {
     // Set my Room ref!
     MyRoom = GetComponentInParent <Room>();
     if (MyRoom == null)
     {
         MyRoom = FindObjectOfType <Room>();
     }                                                          // Also check the whole scene, just in case.
     // Parent me.
     this.transform.SetParent(MyRoom.transform);
     // Unpack me as a Prefab!
     if (UnityEditor.PrefabUtility.IsPartOfAnyPrefab(this.gameObject))
     {
         UnityEditor.PrefabUtility.UnpackPrefabInstance(this.gameObject, UnityEditor.PrefabUnpackMode.Completely, UnityEditor.InteractionMode.AutomatedAction);
     }
     // Set component references!
     if (travelMind == null)
     {
         travelMind = GetComponent <PropTravelMind>();
         if (travelMind != null)   // I DO have a TravelMind? Initialize it as we would've normally.
         {
             travelMind.Initialize(new TravelMindData(travelMind));
         }
     }
 }
Ejemplo n.º 2
0
 public void RemoveTravelMind()
 {
     if (travelMind == null)
     {
         return;
     }                                   // Safety check.
     Destroy(travelMind);
     travelMind = null;
     EnableSnappingScript();
 }
Ejemplo n.º 3
0
 public void AddTravelMind(TravelMindData data)
 {
     if (travelMind != null)
     {
         return;
     }                                   // Safety check.
     travelMind = gameObject.AddComponent <PropTravelMind>();
     travelMind.Initialize(data);
     DisableSnappingScript();
 }
Ejemplo n.º 4
0
 public TravelMindData(PropTravelMind script)
 {
     if (script != null)
     {
         posA      = script.PosA;
         posB      = script.PosB;
         speed     = script.Speed;
         locOffset = script.LocOffset;
     }
     else
     {
         posA      = new Vector2(0, 0);
         posB      = new Vector2(0, 0);
         speed     = 1;
         locOffset = 0;
     }
 }