Example #1
0
        void OnGUI()
        {
            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Advanced Settings");
            if (GUILayout.Button("X"))
            {
                if (m_resultCallback != null)
                {
                    m_resultCallback(Result.Cancel);
                }
                CloseDialog();
            }
            EditorGUILayout.EndHorizontal();

            DaydreamRenderer renderer = FindObjectOfType <DaydreamRenderer>();

            if (renderer == null)
            {
                EditorGUILayout.LabelField("Daydream Renderer Not Enabled");
                return;
            }

            // ------------------------------------------------------------------- //
            // Daydream Lighting Advanced settings
            GUILayout.Space(5);
            DaydreamRendererImportManager.DrawSection(240, 1);
            renderer.m_enableManualLightingComponents = EditorGUILayout.BeginToggleGroup(Styles.toggleComponents, renderer.m_enableManualLightingComponents);
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(Styles.addComponents))
                {
                    DaydreamRendererImportManager.ApplyLightingComponents();
                }
                if (GUILayout.Button(Styles.removeComponents))
                {
                    DaydreamRendererImportManager.RemoveAllLightingComponents();
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndToggleGroup();

            // Add components to FBX and Prefabs not in the scene
            // TODO - rework this UI

            /*
             * EditorGUILayout.BeginHorizontal();
             * if (GUILayout.Button(Styles.addComponentsToProject))
             * {
             *  DaydreamRendererImportManager.ApplyLightingToProject();
             * }
             * if (GUILayout.Button(Styles.removeComponentsFromProject))
             * {
             *  DaydreamRendererImportManager.RemoveAllLightingComponents();
             * }
             * EditorGUILayout.EndHorizontal();
             * //*/
        }
Example #2
0
        void OnGUI()
        {
            if (s_materialHistory == null)
            {
                Configure();
            }

            //---------------------------------------------------------------------//
            // Daydream Material Wizard
            GUILayout.Space(5);
            EditorGUILayout.LabelField(Styles.kTitle, DaydreamRendererImportManager.Styles.sectionLabel, GUILayout.Height(25));
            DaydreamRendererImportManager.DrawSection(500, 1);
            GUILayout.Space(5);

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

            m_UIFade.target = EditorGUILayout.Foldout(m_UIFade.target, "Legend");

            if (EditorGUILayout.BeginFadeGroup(m_UIFade.faded))
            {
                for (int i = 0; i < Styles.matTypeContent.Length; i += 2)
                {
                    EditorGUILayout.BeginHorizontal();

                    // icon
                    EditorGUILayout.LabelField("", Styles.matTypeIcons[i], GUILayout.Width(16));
                    // info
                    EditorGUILayout.LabelField(Styles.matTypeContent[i].tooltip);

                    if (i + 1 < Styles.matTypeContent.Length)
                    {
                        // icon
                        EditorGUILayout.LabelField("", Styles.matTypeIcons[i + 1], GUILayout.Width(16));
                        // info
                        EditorGUILayout.LabelField(Styles.matTypeContent[i + 1].tooltip);
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndFadeGroup();


            GUILayout.Space(10);


            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Convert all materials used in the 'Scene'"))
            {
                List <Material> conversionList = new List <Material>();
                var             iter           = m_infoMap.GetEnumerator();
                while (iter.MoveNext())
                {
                    if (iter.Current.Value[0] != null && iter.Current.Value[0].sceneType > 0)
                    {
                        conversionList.Add(iter.Current.Value[0].m_material);
                    }
                }

                ConvertList(conversionList);

                if (EditorUtility.DisplayDialog(Styles.kTitle, "Would you like to bake vertex lighting now?", "Yes", "No"))
                {
                    DaydreamVertexLightingEditor.OpenWindow();
                }
                else
                {
                    // open up conversion dialog again
                    ShowDialog(null);
                }
            }

            if (GUILayout.Button("Convert all materials used in the 'Project'"))
            {
                List <Material> conversionList = new List <Material>();
                var             iter           = m_infoMap.GetEnumerator();
                while (iter.MoveNext())
                {
                    if (iter.Current.Value[0] != null)
                    {
                        conversionList.Add(iter.Current.Value[0].m_material);
                    }
                }

                ConvertList(conversionList);

                if (EditorUtility.DisplayDialog(Styles.kTitle, "Would you like to bake vertex lighting now?", "Yes", "No"))
                {
                    DaydreamVertexLightingEditor.OpenWindow();
                }
                else
                {
                    // open up conversion dialog again
                    ShowDialog(null);
                }
            }
            EditorGUILayout.EndHorizontal();

            DrawAllMaterials();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            if (GUILayout.Button("Delete All Backup Data"))
            {
                if (EditorUtility.DisplayDialog(Styles.kTitle, "Delete all backup materials, are you sure?", "yes", "no"))
                {
                    for (int i = 0, c = s_materialHistory.m_backupMaterials.Count; i < c; ++i)
                    {
                        DestroyImmediate(s_materialHistory.m_backupMaterials[i], true);
                    }
                    s_materialHistory.m_backupMaterials.Clear();
                }
            }
            if (GUILayout.Button("Export Backups"))
            {
                List <string> assetPaths = new List <string>();
                if (!Directory.Exists(kAssetPathBackup + "/Export"))
                {
                    Directory.CreateDirectory(kAssetPathBackup + "/Export");
                }
                for (int i = 0, c = s_materialHistory.m_backupMaterials.Count; i < c; ++i)
                {
                    if (s_materialHistory.m_backupMaterials[i] != null)
                    {
                        Material copy = new Material(s_materialHistory.m_backupMaterials[i]);
                        copy.name = copy.name.Replace(kBackupPrefix, "");
                        AssetDatabase.CreateAsset(copy, kAssetPathBackup + "/Export/" + copy.name + ".mat");
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                        assetPaths.Add(kAssetPathBackup + "/" + copy.name + ".mat");
                    }
                }
                if (assetPaths.Count > 0)
                {
                    EditorUtility.DisplayDialog(Styles.kTitle, "Materials written to " + kAssetPathBackup + "/Export", "ok");
                }
                else
                {
                    EditorUtility.DisplayDialog(Styles.kTitle, "Nothing to export", "ok");
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (m_repaint)
            {
                List <GameObject> roots = Utilities.GetAllRoots();
                GatherMaterials(roots.ToArray());
                this.Repaint();
            }
        }
Example #3
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");
            }
        }