Ejemplo n.º 1
0
        public static MaterialConversionDialog ShowDialog(ResultCallback resultCallback)
        {
            if (m_instance != null)
            {
                m_instance.CloseDialog();
            }
            m_active         = true;
            m_resultCallback = resultCallback;
            m_instance       = EditorWindow.CreateInstance <MaterialConversionDialog>();

            Vector2 point = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

            m_instance.position = new Rect(point.x, point.y, 250, 900);
            m_instance.minSize  = new Vector2(250, 900);
            Configure();
            m_instance.ShowUtility();
            return(m_instance);
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            bool             settingsChanged = false;
            DaydreamRenderer renderer        = target as DaydreamRenderer;

            Styles.Init();

            //This will add the material to the undo list, at the end of the frame Unity will check if its really changed and if so add it to the undo stack.
            //Since Unity does a binary comparison between the copied data and the original material - it should accurately determine if it has changed.
            //And since we're editing one material at a time, the extra memory (one extra copy of the Material) - the memory cost is reasonable.
            Undo.RecordObject(renderer, "Daydream Renderer Settings");

            DaydreamRendererImportManager.DrawDaydreamLightingToggle(renderer);
            //DaydreamRendererImportManager.DrawSection(500, 1);
            GUILayout.Space(5);

            // Material Conversion
            DaydreamRendererImportManager.DrawSection(500, 1);
            EditorGUILayout.LabelField(DaydreamRendererImportManager.Styles.kConversionWizardSegment, Styles.m_sectionLabel, GUILayout.Height(25));
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(20);
            EditorGUILayout.BeginVertical();
            if (GUILayout.Button(DaydreamRendererImportManager.Styles.kOpenMaterialWizard, EditorStyles.toolbar))
            {
                MaterialConversionDialog.ShowDialog(null);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5);

            renderer.m_shadowSettings = EditorGUILayout.Foldout(renderer.m_shadowSettings, Styles.m_shadowSettingsUI);
            if (renderer.m_shadowSettings)
            {
                EditorGUI.indentLevel = 1;

                EditorGUI.BeginChangeCheck();
                renderer.m_shadowWidth      = EditorGUILayout.IntField(Styles.m_shadowWidthUI, renderer.m_shadowWidth);
                renderer.m_shadowHeight     = EditorGUILayout.IntField(Styles.m_shadowHeightUI, renderer.m_shadowHeight);
                renderer.m_sharpness        = EditorGUILayout.Slider(Styles.m_shadowSharpnessUI, renderer.m_sharpness, 0.0f, 1.0f);
                renderer.m_maxShadowCasters = EditorGUILayout.IntSlider(Styles.m_maxShadowCastersUI, renderer.m_maxShadowCasters, 0, 4);
                if (EditorGUI.EndChangeCheck())
                {
                    settingsChanged = true;
                }

                EditorGUI.indentLevel = 0;

                renderer.UpdateFilterParam();
            }

            renderer.m_ambientSettings = EditorGUILayout.Foldout(renderer.m_ambientSettings, Styles.m_ambientSettingsUI);
            if (renderer.m_ambientSettings)
            {
                EditorGUI.indentLevel = 1;

                EditorGUI.BeginChangeCheck();
                renderer.m_globalAmbientUp = EditorGUILayout.ColorField(Styles.m_ambientUpUI, renderer.m_globalAmbientUp);
                renderer.m_globalAmbientDn = EditorGUILayout.ColorField(Styles.m_ambientDownUI, renderer.m_globalAmbientDn);
                if (EditorGUI.EndChangeCheck())
                {
                    settingsChanged = true;
                    renderer.UpdateAmbientParam();
                    EditorUtility.SetDirty(renderer);
                }

                EditorGUI.indentLevel = 0;
            }

            renderer.m_fogSettings = EditorGUILayout.Foldout(renderer.m_fogSettings, Styles.m_fogSettingsUI);
            if (renderer.m_fogSettings)
            {
                EditorGUI.indentLevel = 1;

                EditorGUI.BeginChangeCheck();
                renderer.m_fogEnable       = EditorGUILayout.Toggle(Styles.m_fogEnable, renderer.m_fogEnable);
                renderer.m_heightFogEnable = EditorGUILayout.Toggle(Styles.m_fogHeightEnable, renderer.m_heightFogEnable);
                renderer.m_fogMode         = EditorGUILayout.Popup(Styles.m_fogModeLabel, renderer.m_fogMode, Styles.m_fogModes);

                EditorGUILayout.Space();

                if (renderer.m_fogMode == DaydreamRenderer.FogMode.Linear)
                {
                    renderer.m_fogLinear.x = EditorGUILayout.Slider(Styles.m_fogNear, renderer.m_fogLinear.x, 0.0f, 1000.0f);
                    renderer.m_fogLinear.y = EditorGUILayout.Slider(Styles.m_fogFar, renderer.m_fogLinear.y, 0.0f, 10000.0f);
                }
                if (renderer.m_fogMode != DaydreamRenderer.FogMode.Linear)
                {
                    renderer.m_fogHeight.w = EditorGUILayout.Slider(Styles.m_fogDensity, renderer.m_fogHeight.w, 0.0f, 1.0f);
                }

                renderer.m_fogLinear.z = EditorGUILayout.Slider(Styles.m_fogOpacity, renderer.m_fogLinear.z, 0.0f, 1.0f);
                renderer.m_fogLinear.w = EditorGUILayout.Slider(Styles.m_fogColorScale, renderer.m_fogLinear.w, 0.0f, 4.0f);

                if (renderer.m_heightFogEnable)
                {
                    renderer.m_fogHeight.x = EditorGUILayout.Slider(Styles.m_fogMinHeight, renderer.m_fogHeight.x, -100.0f, 100.0f);
                    renderer.m_fogHeight.y = EditorGUILayout.Slider(Styles.m_fogMaxHeight, renderer.m_fogHeight.y, -100.0f, 100.0f);
                    renderer.m_fogHeight.z = EditorGUILayout.Slider(Styles.m_fogThickness, renderer.m_fogHeight.z, 0.0f, 100.0f);
                }

                renderer.m_fogColorNear = EditorGUILayout.ColorField(Styles.m_fogColorNear, renderer.m_fogColorNear);
                renderer.m_fogColorFar  = EditorGUILayout.ColorField(Styles.m_fogColorFar, renderer.m_fogColorFar);
                if (EditorGUI.EndChangeCheck())
                {
                    settingsChanged = true;
                    renderer.UpdateFogParam();
                    EditorUtility.SetDirty(renderer);
                }

                EditorGUI.indentLevel = 0;
            }

            renderer.m_showFPS = EditorGUILayout.Toggle(Styles.m_showFpsUI, renderer.m_showFPS);

    #if UNITY_EDITOR
            if (settingsChanged && !Application.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
    #endif
        }
        void OnGUI()
        {
            DrawCenteredLogo(100);

            DaydreamRenderer renderer = FindObjectOfType <DaydreamRenderer>();

            if (renderer == null)
            {
                m_UIFade.target = false;

                EditorGUILayout.LabelField(Styles.ddrNotEnabled, Styles.helpText);

                GUILayout.Space(10);

                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (DREditorUtility.FlexibleHorizButton(Styles.kAddDrToScene, Styles.boldButton, GUILayout.Width(280), GUILayout.Height(50)))
                {
                    GameObject go = GameObject.Find(kDaydreamObjectName);
                    if (go == null)
                    {
                        go = new GameObject(kDaydreamObjectName);
                    }

                    go.AddComponent <DaydreamRenderer>();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();

                return;
            }
            else
            {
                m_UIFade.target = true;
            }

            //---------------------------------------------------------------------//
            // Daydream lighting
            if (EditorGUILayout.BeginFadeGroup(m_UIFade.faded))
            {
                EditorGUILayout.LabelField(Styles.kDaydreamEnabled, Styles.helpText);

                DrawDaydreamLightingToggle(renderer);
            }
            EditorGUILayout.EndFadeGroup();


            //---------------------------------------------------------------------//
            // Material conversion
            GUILayout.Space(10);
            DaydreamRendererImportManager.DrawSection(500, 1);
            EditorGUILayout.LabelField(Styles.kConversionWizardSegment, DaydreamRendererImportManager.Styles.sectionLabel, GUILayout.Height(25));
            GUILayout.Space(5);

            EditorGUILayout.HelpBox(Styles.kMaterialWizardInfo, MessageType.Info);

            if (GUILayout.Button(Styles.kOpenMaterialWizard))
            {
                MaterialConversionDialog.ShowDialog(null);
            }

            //---------------------------------------------------------------------//
            // Documentation
            GUILayout.Space(10);
            DaydreamRendererImportManager.DrawSection(500, 1);
            EditorGUILayout.LabelField("Documentation", DaydreamRendererImportManager.Styles.sectionLabel, GUILayout.Height(25));
            if (GUILayout.Button(Styles.kOpenDocumentation))
            {
                Application.OpenURL("https://github.com/googlevr/daydream-renderer-for-unity/blob/master/README.md");
            }
        }