need help with scriptablewizard

hi
i need help with my script
i need to add some material to my objects.so i need to make this.
i worked on it but i couldn’t make it. can somebody help me ,please.

here is the code:

class addMaterial extends ScriptableWizard {	
	var replace : boolean;
    var Materials : Material[];

    @MenuItem ("Scripts/Add materials")
    static function CreateWizard () {
        ScriptableWizard.DisplayWizard("Add materials", typeof (addMaterial),"Apply");
    }
    
    function OnWizardCreate () {
		if(replace){
			for(var obj in Selection.objects){
				obj.renderer.materials=Materials;
			}
		}else{
			for(var obj in Selection.objects){
				var a : Material[] = obj.renderer.materials;
				var New = new Material[a.length+Materials.length];
				New = a+Materials;
				print(New.length);
				//obj.renderer.materials=new Material[New.length];
				//obj.renderer.materials=New;
/* 				for(var i in Materials){
 					obj.renderer.materials+=1;
					obj.renderer.materials[obj.renderer.materials.length]=i;
 				}*/
			}
		}
	}
    
    function OnWizardUpdate () {
        helpString = "Please set the material you want to add.";
    }
}

thank you

If you use JS arrays, you can use the Concat function to join two or more arrays into one. If you need to use built-in arrays throughout, you need to copy the elements of the two original arrays into a larger array using loops or with the Array.Copy function from the Mono library.