add and layout lightprobes using an editor script

Hey,
I’m trying to build an editor script that will help me with placing lightprobes. But I cannot find how to add the probes to a lightprobegroup from script.
Does anyone know how to do this? Or any help as to where I can find the answer?
Thanks!
Vin

Update:

I see now that LightProbeGroup.probePositions = just a vector3 array that can be sized how you want.
Below is my script so far. The problem is that the lightprobes positions reset to 0 0 0

If I log the values right after I set them they log correctly. But if I log them afterwards, they are back at 0 0 0
I’ve tried to use editorUtility.setDirty on lpGrp but that doesn’t help.

Anyone now how to stop it from resetting?

Thanks!

class lightProbePlacer extends EditorWindow 
{
	
	@MenuItem ("Custom/lightProbePlacer")
	static function Init () 
	{
		var window : lightProbePlacer = EditorWindow.GetWindow (lightProbePlacer);
		window.Show (); 
	}
	
	var currentProbeObject : GameObject;
	var lpGrp : LightProbeGroup;
	var lpPositions : Vector3[];
	var xStart : float;
		
	function OnGUI () 
	{
		
		GUILayout.BeginArea (Rect (20,80,300,200));
	
		//Create probe group
		if (GUI.Button(Rect(0,0,80,30),"create probe volume"))
		{
			currentProbeObject = new GameObject ("lightProbes");
			currentProbeObject.AddComponent ("LightProbeGroup");
		}
		
		//add and place lightprobes
		if (GUI.Button(Rect(0,40,80,30),"build 10"))
		{
			lpGrp = Selection.activeGameObject.GetComponent(LightProbeGroup) as LightProbeGroup;
			lpGrp.probePositions = new Vector3[10];
			lpPositions = lpGrp.probePositions;

			for (i = 0; i < lpPositions.length; i++)
			{
				lpPositions *= Vector3(xStart,0.0,0.0);*
  •  		xStart += 10;*
    
  •  	}*
    
  •  }*
    
  •  GUILayout.EndArea ();*
    
  • }*

}
Update 2:
Support suggested that I first create a new array and then replace the probepositions with that. But that also does not work.
Any ideas?

Hey,

It seems that you cannot use the built in array’s with the lightprobes… Here is a functional script:

Hope it helps someone else!

cheers!

class lightProbePlacer extends EditorWindow 
{
	
	@MenuItem ("Custom/lightProbePlacer")
	static function Init () 
	{
		var window : lightProbePlacer = EditorWindow.GetWindow (lightProbePlacer);
		window.Show (); 
	}
	
	var currentProbeObject : GameObject;
	var lpGrp : LightProbeGroup;
	var xStart : float;
		
	function OnGUI () 
	{
		
		GUILayout.BeginArea (Rect (20,80,300,200));
	
		//Create probe group
		if (GUI.Button(Rect(0,0,200,30),"create probe volume"))
		{
			currentProbeObject = new GameObject ("lightProbes");
			currentProbeObject.AddComponent ("LightProbeGroup");
		}
		
		  //add and place lightprobes
		if (GUI.Button(Rect(0,40,100,30),"build 10 in a line"))
		{
			xStart = 0.0;
			lpGrp = Selection.activeGameObject.GetComponent(LightProbeGroup);
			var lpPositions = new Array();
			
			for (i = 0; i < 10; i++)
			{
				lpPositions.Add(Vector3(xStart,0.0,0.0));
				xStart += 10;
			}
			
			lpGrp.probePositions = lpPositions;
		}
		
	
		GUILayout.EndArea ();
	}
	
}