private void Awake() { try { Debug.Log($"Creating a scene controller of type {SceneControllerClass}"); gameObject.SetActive(false); Type controllerType = CoreUtils.GetLoadedTypes() .Where(t => t.Name == SceneControllerClass) //.Where(t => t.Name.EndsWith(SceneControllerClass)) .Single(); MonoBehaviour controller = (MonoBehaviour)gameObject.AddComponent(controllerType); ProxyUtils.SetProxyFields(this, controller); //this call does 90% of the magic //fires awake, probably gameObject.SetActive(true); //it will also fire OnEnable and OnDisable //that _shouldn't_ be a problem but if we need to we can re-root the world } catch (Exception e) { Debug.LogError($"Error setting up proxied scene controller {e.GetType().Name}"); Debug.LogException(e); } finally { gameObject.SetActive(true); } }
#pragma warning restore 0414 //we actually just create an EntityPlaceholder private void Awake() { Type placeholderType = CCBase.BaseGameTypes .Where(t => t.FullName == "CommonCore.World.EntityPlaceholder") .Single(); MonoBehaviour controller = (MonoBehaviour)gameObject.AddComponent(placeholderType); ProxyUtils.SetProxyFields(this, controller); }