x


Custom Editor Problems Loading created objects

I have a level editor that creates a 2d grid of hexs. I can create the objects no problem but when I start up the game they are all gone. I have worked around it and have a poor solution by grabbing all objects of type hex and putting them into the array again. That doesn't seem right to me.

Also when I create a grid and ajust all the properties of the hexs, then load the game it all works. But if I close unity and open the scene up none of it works.

I can give more details if needed but I'm not sure what else to write.

@CustomEditor ( HexEditor )

class CustomLevelEditor extends Editor {

function OnInspectorGUI ()
{
    target.row= EditorGUILayout.IntField("Row", target.row);
    target.column= EditorGUILayout.IntField("Column", target.column);
    target.HexObject= EditorGUILayout.ObjectField("Hex", target.HexObject, GameObject);     


    if( GUI.Button( Rect( 0, 340, 200, 20 ), "Destroy Grid" ) )
    {
        target.DestroyGrid();                       
    }   
    if( GUI.Button( Rect( 0, 360, 200, 20 ), "Create Grid" ) )
    {
        target.CreateHexGrid();
        target.InitalizeProjectors();           
    }   

    if( GUI.Button( Rect( 0, 380, 200, 20 ), "Toggle Projectors" ) )
    {
        target.ToggleProjectors();          
    }       
    if (GUI.changed)
    {
        EditorUtility.SetDirty (target);
    }
}

}

more ▼

asked Jun 09 '10 at 04:44 AM

Mike 4 gravatar image

Mike 4
37 7 7 10

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

0 answers: sort voted first
Be the first one to answer this question
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:

x1677
x199

asked: Jun 09 '10 at 04:44 AM

Seen: 876 times

Last Updated: Jun 09 '10 at 04:44 AM