x


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[i] = 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?

more ▼

asked Mar 31 '12 at 07:31 AM

Jaywalker gravatar image

Jaywalker
529 15 21 30

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

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 ();
    }

}
more ▼

answered Apr 09 '12 at 10:20 AM

Jaywalker gravatar image

Jaywalker
529 15 21 30

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x351
x9

asked: Mar 31 '12 at 07:31 AM

Seen: 400 times

Last Updated: Apr 09 '12 at 10:20 AM