// these should be called by parent Unity functions public void Start(ICockpitInitializer setup) { // create invisible plane for cockpit gameobject = GameObject.CreatePrimitive(PrimitiveType.Plane); gameobject.SetName("cockpit"); MeshRenderer ren = gameobject.GetComponent <MeshRenderer> (); ren.enabled = false; gameobject.GetComponent <MeshCollider> ().enabled = false; // add hud animation controller gameobject.AddComponent <UnityPerFrameAnimationBehavior>().Animator = HUDAnimator; // create HUD try { setup.Initialize(this); } catch (Exception e) { DebugUtil.Log(2, "[Cockpit.Start] exception in initializer: {0}\nTrace:\n{1}", e.Message, e.StackTrace); // if hud setup fails we still want to keep going } // position in front of camera UpdateTracking(true); }
// called by FContext.PushCockpit() public void Start(ICockpitInitializer setup) { // create invisible plane for cockpit gameobject = GameObjectFactory.CreateParentGO("cockpit"); onCameraGO = GameObjectFactory.CreateParentGO("cockpit_camera"); gameobject.AddChild(onCameraGO, false); // add hud animation controller gameobject.AddComponent <UnityPerFrameAnimationBehavior>().Animator = HUDAnimator; // create HUD try { setup.Initialize(this); } catch (Exception e) { // if hud setup fails we still want to keep going DebugUtil.Log(2, "[Cockpit.Start] exception in initializer: {0}\nTrace:\n{1}", e.Message, e.StackTrace); if (FPlatform.InUnityEditor()) { throw; } } // position in front of camera UpdateTracking(true); }
public void PushCockpit(ICockpitInitializer initializer) { Cockpit trackingInitializer = null; if (activeCockpit != null) { trackingInitializer = activeCockpit; inputBehaviors.Remove(activeCockpit.InputBehaviors); overrideBehaviors.Remove(activeCockpit.OverrideBehaviors); cockpitStack.Push(activeCockpit); activeCockpit.RootGameObject.SetActive(false); } Cockpit c = new Cockpit(this); activeCockpit = c; if (Use2DCockpit) { c.UIElementLayer = FPlatform.UILayer; } c.Start(initializer); if (trackingInitializer != null) { c.InitializeTracking(trackingInitializer); } inputBehaviors.Add(c.InputBehaviors); overrideBehaviors.Add(c.OverrideBehaviors); mouseCursor.ResetCursorToCenter(); }