Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            LevelDistance myScript = (LevelDistance)target;

            EditorGUILayout.Space();
            serializedObject.Update();
            LevelDistanceEditorList.Show(serializedObject.FindProperty("cameraDistanceFactor"), this);
            LevelDistanceEditorList.Show(serializedObject.FindProperty("levelDetailGroup"), this);
            LevelDistanceEditorList.Show(serializedObject.FindProperty("groupLevelDistances"), this);
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 2
0
        public void OnEnable()
        {
            LevelDistance myScript = (LevelDistance)target;

            myScript.levelDetailGroup = myScript.gameObject.GetComponent <LODGroup>();
            if (myScript.cameraDistanceFactor == -1)
            {
                myScript.cameraDistanceFactor = ExporterWindow.exportationOptions.CameraDistanceFactor;
            }
            RecalculateLevelDistances();
        }
Esempio n. 3
0
        public void RecalculateLevelDistances()
        {
            LevelDistance myScript = (LevelDistance)target;

            if (myScript.levelDetailGroup != null)
            {
                myScript.groupLevelDistances.Clear();
                var   lodGroup         = myScript.levelDetailGroup;
                float nearClipingPlane = (Camera.main != null) ? Camera.main.nearClipPlane : 0.3f;
                float farClipingPlane  = (Camera.main != null) ? Camera.main.farClipPlane : 1000.0f;
                LOD[] lods             = lodGroup.GetLODs();
                float startingPercent  = -1f;
                float endingPercent    = -1f;
                float lastPercent      = 0f;
                int   startRange       = 0;
                int   index            = 0;
                foreach (var lod in lods)
                {
                    endingPercent = lod.screenRelativeTransitionHeight;
                    if (startingPercent == -1)
                    {
                        startingPercent = 1;
                    }
                    else
                    {
                        startingPercent = lastPercent;
                    }
                    float  lodDistance  = startingPercent - endingPercent;
                    string lodFormatted = String.Format("LOD{0} - Distance: {1}", index.ToString(), startRange.ToString());
                    myScript.groupLevelDistances.Add(lodFormatted);
                    lastPercent = endingPercent;
                    startRange += Unity3D2Babylon.Tools.CalculateCameraDistance(nearClipingPlane, farClipingPlane, lodDistance, myScript);
                    index++;
                }
                float  startCulling     = startRange;
                string cullingFormatted = String.Format("LODX - Distance: {0}", startCulling.ToString());
                myScript.groupLevelDistances.Add(cullingFormatted);
            }
        }