Exemplo n.º 1
0
    public static ILConfig DeserializeFromString(string configString)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(ILConfig));
        TextReader    reader     = new StringReader(configString);
        ILConfig      config     = (ILConfig)serializer.Deserialize(reader);

        return(config);
    }
Exemplo n.º 2
0
    public static ILConfig DeserializeFromPath(string path)
    {
        FileInfo info = new FileInfo(path);

        if (!info.Exists)
        {
            return(null);
        }

        XmlSerializer serializer = new XmlSerializer(typeof(ILConfig));
        FileStream    stream     = new FileStream(path, FileMode.Open);

        ILConfig config = (ILConfig)serializer.Deserialize(stream);

        stream.Close();

        return(config);
    }
Exemplo n.º 3
0
    void OnGUI()
    {
        string path = ConfigFilePath;
        if (string.IsNullOrEmpty (path)) {
            EditorGUILayout.HelpBox ("Open a scene file to edit its lightmapping settings.", MessageType.Info);
            return;
        }

        // Determine if config file exists
        bool haveConfigFile = false;
        if (sc.config == null) {
            if (File.Exists (path)) {
                sc.config = ILConfig.DeserializeFromPath (path);
                haveConfigFile = true;
            }
        } else {
            haveConfigFile = true;
        }

        // Option to generate a config file
        if (!haveConfigFile) {
            EditorGUILayout.Space ();
            if (GUILayout.Button ("Generate Beast settings file for current scene")) {
                SetPresetToDefault ();
                ILConfig newConfig = new ILConfig ();
                var dir = Path.GetDirectoryName (ConfigFilePath);
                if (!Directory.Exists (dir))
                    Directory.CreateDirectory (dir);
                newConfig.SerializeToPath (ConfigFilePath);
                sc.config = ILConfig.DeserializeFromPath (path);
                AssetDatabase.Refresh ();
                GUIUtility.ExitGUI ();
            }
            return;
        }

        EditorGUILayout.Space ();

        PresetSelectionGUI ();

        EditorGUILayout.Space ();

        int lastSelected = toolbarSelected;
        toolbarSelected = GUILayout.Toolbar (toolbarSelected, new string[] {"Settings", "Global Illum", "Environment"});
        // Prevent text fields from grabbing focus when switching tabs
        if (toolbarSelected != lastSelected) {
            GUI.FocusControl ("");
        }

        EditorGUILayout.Space ();

        scroll = EditorGUILayout.BeginScrollView (scroll);
        {
            SerializedObject configObj = new SerializedObject (sc);
            switch (toolbarSelected) {
            case 0:
                PerformanceSettingsGUI (configObj);
                TextureBakeGUI (configObj);
                AASettingsGUI (configObj);
                RenderSettingsGUI (configObj);
                break;
            case 1:
                GlobalIlluminationGUI (configObj);
                break;
            case 2:
                EnvironmentGUI (configObj);
                break;
            }

            if (GUI.changed) {
                configObj.ApplyModifiedProperties ();
                SaveConfig ();
            }
        }

        EditorGUILayout.EndScrollView ();

        EditorGUILayout.Space ();
        GUILayout.BeginHorizontal ();
        {
            BakeButtonsGUI ();
        }
        GUILayout.EndHorizontal ();
        EditorGUILayout.Space ();

        // Use FocusControl to release focus from text fields when switching tabs
        GUI.SetNextControlName ("");
    }
Exemplo n.º 4
0
 private void LMColorPicker(string name, ref ILConfig.LMColor color, string tooltip)
 {
     Color c = EditorGUILayout.ColorField (new GUIContent (name, tooltip), new Color (color.r, color.g, color.b, color.a));
     color = new ILConfig.LMColor (c.r, c.g, c.b, c.a);
 }
Exemplo n.º 5
0
    void IntegratorSettings(SerializedObject serializedObject, ILConfig.GISettings.Integrator integrator, bool isPrimary)
    {
        if (integrator != ILConfig.GISettings.Integrator.None) {
            if (isPrimary) {
                SerializedProperty primaryIntensity = serializedObject.FindProperty ("config.giSettings.primaryIntensity");
                SerializedProperty primarySaturation = serializedObject.FindProperty ("config.giSettings.primarySaturation");
                EditorGUILayout.PropertyField (primaryIntensity, new GUIContent ("Intensity", "Tweak the amount of illumination from the primary and secondary GI integrators. This lets you boost or reduce the amount of indirect light easily."));
                EditorGUILayout.PropertyField (primarySaturation, new GUIContent ("Saturation", "Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost or reduce the perceived saturation of the bounced light."));
            } else {
                SerializedProperty secondaryIntensity = serializedObject.FindProperty ("config.giSettings.secondaryIntensity");
                SerializedProperty secondarySaturation = serializedObject.FindProperty ("config.giSettings.secondarySaturation");
                EditorGUILayout.PropertyField (secondaryIntensity, new GUIContent ("Intensity", "Tweak the amount of illumination from the primary and secondary GI integrators. This lets you boost or reduce the amount of indirect light easily."));
                EditorGUILayout.PropertyField (secondarySaturation, new GUIContent ("Saturation", "Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost or reduce the perceived saturation of the bounced light."));
            }
        }

        switch (integrator) {
        case ILConfig.GISettings.Integrator.None:
            if (isPrimary && sc.config.giSettings.primaryIntegrator != ILConfig.GISettings.Integrator.None)
                sc.config.giSettings.primaryIntegrator = ILConfig.GISettings.Integrator.None;
            else if (!isPrimary && sc.config.giSettings.secondaryIntegrator != ILConfig.GISettings.Integrator.None)
                sc.config.giSettings.secondaryIntegrator = ILConfig.GISettings.Integrator.None;
            break;
        case ILConfig.GISettings.Integrator.FinalGather:
            FinalGatherSettings (serializedObject, isPrimary);
            break;
        case ILConfig.GISettings.Integrator.PathTracer:
            PathTracerSettings (serializedObject, isPrimary);
            break;
        case ILConfig.GISettings.Integrator.MonteCarlo:
            MonteCarloSettings (serializedObject, isPrimary);
            break;
        }
    }