change various Prefabs (primitives) with a Gui.Button // switching Prefabs

i like change my prefabs using a Gui.Button //i'm using two button :

[<>] // Next Prefab

this for customize menu

how can i do this?

This is mainly untested psudocode. I’m normally using c# so i hope my translation is not too bad.

  1. We put all or prefabs that we want to scroll through in a public gameobject array: GameObject myPrefabs.

  2. To loop through we declare an integer called an “activeIndex”. This is the one thats incharge of letting oyu know which prefab is currently being selected.

  3. Then the code to do it:

        var myPrefabs:GameObject[];
        var ActiveIndex:int = 0;
        var ActivePrefab:GameObject = null;
    function OnGUI(){
    
    
    if( 0 != ActiveIndex){
    if (GUI.Button (Rect(0,0, 50,50), "Prev")){
         ActiveIndex--;
         ActivePrefab = myPrefabs[ActiveIndex];
    }
    

    }

    if( myPrefabs.Length - 1 > ActiveIndex){
    
    if (GUI.Button (Rect(50,0, 50,50), "Next")){
         ActiveIndex++;
         ActivePrefab = myPrefabs[ActiveIndex];         
    }
    }
    

    }

hello i m test the script and have wrong i’m work in the same script
how can i do ?
for example i’m have 4 prefab: geometry_a, geometry_b geometry_c, geometry_d