示例#1
0
        public void BuildLightingScenario(int ScenarioID, LevelLightmapData levelLightmapData)
        {
            //Remove reference to LightingDataAsset so that Unity doesn't delete the previous bake
            Lightmapping.lightingDataAsset = null;

            string currentBuildScenename = lightingScenariosScenes.GetArrayElementAtIndex(ScenarioID).objectReferenceValue.name;

            Debug.Log("Loading " + currentBuildScenename);

            string lightingSceneGUID = AssetDatabase.FindAssets(currentBuildScenename)[0];
            string lightingScenePath = AssetDatabase.GUIDToAssetPath(lightingSceneGUID);

            if (!lightingScenePath.EndsWith(".unity"))
            {
                lightingScenePath = lightingScenePath + ".unity";
            }

            EditorSceneManager.OpenScene(lightingScenePath, OpenSceneMode.Additive);

            Scene lightingScene = SceneManager.GetSceneByName(currentBuildScenename);

            EditorSceneManager.SetActiveScene(lightingScene);

            SearchLightsNeededRealtime(levelLightmapData);

            Debug.Log("Start baking");
            EditorCoroutineUtility.StartCoroutine(BuildLightingAsync(lightingScene), this);
        }
示例#2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            LevelLightmapData lightmapData = (LevelLightmapData)target;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(lightingScenariosScenes, new GUIContent("Lighting Scenarios Scenes"), includeChildren: true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                lightingScenesNames.arraySize = lightingScenariosScenes.arraySize;

                for (int i = 0; i < lightingScenariosScenes.arraySize; i++)
                {
                    lightingScenesNames.GetArrayElementAtIndex(i).stringValue = lightingScenariosScenes.GetArrayElementAtIndex(i).objectReferenceValue == null ? "" : lightingScenariosScenes.GetArrayElementAtIndex(i).objectReferenceValue.name;
                }
                serializedObject.ApplyModifiedProperties();
            }
            EditorGUILayout.PropertyField(allowLoadingLightingScenes, allowLoading);
            EditorGUILayout.PropertyField(applyLightmapScaleAndOffset);

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.Space();

            for (int i = 0; i < lightmapData.lightingScenariosScenes.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (lightmapData.lightingScenariosScenes[i] != null)
                {
                    EditorGUILayout.LabelField(lightmapData.lightingScenariosScenes[i].name.ToString(), EditorStyles.boldLabel);
                    if (GUILayout.Button("Build "))
                    {
                        if (UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand)
                        {
                            Debug.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled.");
                        }
                        else
                        {
                            BuildLightingScenario(i, lightmapData);
                        }
                    }
                    if (GUILayout.Button("Store "))
                    {
                        lightmapData.StoreLightmapInfos(i);
                    }
                    if (GUILayout.Button("Load "))
                    {
                        lightmapData.LoadLightingScenario(i);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
        }
示例#3
0
        public void SearchLightsNeededRealtime(LevelLightmapData levelLightmapData)
        {
            bool latestBuildHasRealtimeLights = false;

            var lights           = FindObjectsOfType <Light>();
            var reflectionProbes = FindObjectsOfType <ReflectionProbe>();

            foreach (Light light in lights)
            {
                if (light.lightmapBakeType == LightmapBakeType.Mixed || light.lightmapBakeType == LightmapBakeType.Realtime)
                {
                    latestBuildHasRealtimeLights = true;
                }
            }
            if (reflectionProbes.Length > 0)
            {
                latestBuildHasRealtimeLights = true;
            }

            levelLightmapData.latestBuildHasReltimeLights = latestBuildHasRealtimeLights;
        }
示例#4
0
 public void BindLightmapData(LevelLightmapData data)
 {
     lightMapData = data;
 }