Beispiel #1
0
        /// <summary>
        /// Called before the view is loaded.
        /// </summary>
        protected override void BeforeLoad()
        {
            base.BeforeLoad();
            if (IgnoreObject)
            {
                return;
            }

            // create game-object and parent it with first scene object parent (that is not set to be ignored)
            const int GuidIdLength = 36;
            var       go           = new UnityEngine.GameObject(String.Format("{0}{1}", GetType().Name, Id.Length != GuidIdLength ? " (" + Id + ")" : ""));
            var       parent       = this.FindParent <SceneObjectView>(x => !x.IgnoreObject);

            if (parent != null)
            {
                go.transform.SetParent(parent.GameObject.transform, false);
            }
            GameObject = go;

            // if script events are enabled add component that relays the events
            if (EnableScriptEvents)
            {
                _unityScriptRelay = go.AddComponent <UnityScriptRelay>();
                _unityScriptRelay.SceneObjectView = this;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Called when EnableScriptEvents has been changed.
 /// </summary>
 private void EnableScriptEventsChanged()
 {
     if (EnableScriptEvents)
     {
         if (GameObject.GetComponent <UnityScriptRelay>())
         {
             return; // already has script relay
         }
         _unityScriptRelay = GameObject.AddComponent <UnityScriptRelay>();
         _unityScriptRelay.SceneObjectView = this;
     }
 }