Example #1
0
        // 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);
        }
Example #2
0
        public float GetPixelScale()
        {
            AxisAlignedBox2f uiBounds    = GetOrthoViewBounds();
            AxisAlignedBox2f pixelBounds = GetPixelViewBounds();
            float            fScale      = uiBounds.MaxDim / pixelBounds.MaxDim;

#if UNITY_STANDALONE_OSX
            if (UnityEngine.Screen.dpi > 100.0f && FPlatform.InUnityEditor() == false)
            {
                fScale /= 2.0f;
            }
#endif
#if UNITY_IOS || UNITY_ANDROID
            if (FPlatform.GetDeviceType() != FPlatform.fDeviceType.IPad)
            {
                fScale *= 0.8f;
            }
#endif
            if (FPlatform.InUnityEditor())
            {
                fScale *= FPlatform.EditorUIScaleFactor;
            }
            else
            {
                fScale *= FPlatform.UIScaleFactor;
            }
            return(fScale);
        }
Example #3
0
 public SceneOptions()
 {
     EnableDefaultLighting = true;
     EnableCockpit         = true;
     EnableTransforms      = true;
     CockpitInitializer    = null;
     SceneInitializer      = null;
     MouseCameraControls   = null;
     UseSystemMouseCursor  = false;
     Use2DCockpit          = false;
     ConstantSize2DCockpit = false;
     // default logging level is to be verbose in editor
     LogLevel = FPlatform.InUnityEditor() ? 1 : 0;
 }
Example #4
0
        /// <summary>
        /// Returns dpi-independent pixel scaling factor. Mainly intended to be used
        /// for sizing UI elements.
        /// This function multiplies by FPlatform.PixelScaleFactor.
        /// </summary>
        public float GetPixelScale(bool bDpiIndependent = true)
        {
            AxisAlignedBox2f uiBounds    = GetOrthoViewBounds();
            AxisAlignedBox2f pixelBounds =
                (bDpiIndependent) ? GetPixelViewBounds_DpiIndependent() : GetPixelViewBounds_Absolute();
            float fScale = uiBounds.Height / pixelBounds.Height;

            // use ValidScreenDimensionRange to manipulate scale here?

            if (FPlatform.InUnityEditor())
            {
                fScale *= FPlatform.EditorPixelScaleFactor;
            }
            else
            {
                fScale *= FPlatform.PixelScaleFactor;
            }
            return(fScale);
        }