Пример #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));
         }
     }
 }
Пример #2
0
 public void AddTravelMind(TravelMindData data)
 {
     if (travelMind != null)
     {
         return;
     }                                   // Safety check.
     travelMind = gameObject.AddComponent <PropTravelMind>();
     travelMind.Initialize(data);
     DisableSnappingScript();
 }