Add new light rails and prefabs
This commit is contained in:
45
Assets/Scripts/LightProbeGroupMerger.cs
Normal file
45
Assets/Scripts/LightProbeGroupMerger.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class LightProbeGroupMerger
|
||||
{
|
||||
const string MergedLightProbeGroupName = "MergedLightProbeGroup";
|
||||
|
||||
[MenuItem("Tools/Lights/Merge Light Probe Groups")]
|
||||
static void MergeLightProbeGroups()
|
||||
{
|
||||
var lightProbeGroups = GameObject.FindObjectsOfType<LightProbeGroup>();
|
||||
if (lightProbeGroups.Length > 1)
|
||||
{
|
||||
// Collect light probe positions from all light probe groups in the scene.
|
||||
var mergedLightProbePositions = new List<Vector3>();
|
||||
foreach (var lightProbeGroup in lightProbeGroups)
|
||||
{
|
||||
foreach (var lightProbePosition in lightProbeGroup.probePositions)
|
||||
{
|
||||
mergedLightProbePositions.Add(lightProbeGroup.transform.TransformPoint(lightProbePosition));
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new light probe group that merges all the light probe positions.
|
||||
var newGameObject = new GameObject(MergedLightProbeGroupName);
|
||||
Undo.RegisterCreatedObjectUndo(newGameObject, $"Created {MergedLightProbeGroupName}");
|
||||
var mergedLightProbeGroup = newGameObject.AddComponent<LightProbeGroup>();
|
||||
mergedLightProbeGroup.probePositions = mergedLightProbePositions.ToArray();
|
||||
|
||||
// Destroy the old individual light probe groups.
|
||||
foreach (var lightProbeGroup in lightProbeGroups)
|
||||
{
|
||||
if (lightProbeGroup != null && lightProbeGroup.gameObject != null)
|
||||
{
|
||||
Undo.DestroyObjectImmediate(lightProbeGroup.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"Merged {mergedLightProbePositions.Count} light probes from {lightProbeGroups.Length} light probe groups into '{MergedLightProbeGroupName}'.");
|
||||
|
||||
Selection.activeObject = newGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/LightProbeGroupMerger.cs.meta
Normal file
11
Assets/Scripts/LightProbeGroupMerger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f5f66e519226be4a8b6732f4c24b3e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user