It’s messy. But I’ll try…
I’ll paste code only associated with Model Model List.
STANDARD ASSETS
ProcedualClasses - contains all the classes for generating the space.
class Level{
..vars..
var GameRoomTypeList : RoomType[] = new RoomType[1] ;
var Models : Model[] = new Model[1];
var ModelList : ModelList[] = new ModelList[1];
..vars..
..functions..
}//end of Level class function
class Model { //block that is used to store building parts. Walls, floors, ect.
//Contains basic details about archetexturaal models.
var name : String;
var model : GameObject[] = new GameObject[1]; //allows use of prefabs. //For walls, 0 = plain, 1 = inside, 2 = outside, 3 = door
var min_Height : float = 0;//how far below 0.0 this goes
var max_Height : float = 1;//How tall this is
function DuplicateModel() :Model{ //This function is used so variables won't share same memory when needed.
var m : Model;
m.name = name;
m.model = model;
m.min_Height = min_Height;
m.max_Height = max_Height;
return m;
}
..functions..
}//End of Model class
[CODE]
class ModelList{
var name : String;
var description : String;
var models : Model[];
function DuplicateList() : ModelList{ //Used to add a new variable to the array, but not use same memory.
var newList : ModelList;
newList.models = new Model[models.length]; //models.length
newList.name = name;
newList.description = description;
newList.models = models;
for (i = 0 ; i > newList.models.length ; ++i){
//newList.models[i] = models[i];
}
return newList;
}
}//End of ModelList class
[/CODE]SCRIPTS A simple setup script exists. Very little of mainLevel is modified ingame.
GeneratingDummy.js
var mainLevel : Level;
var passcount :int = 5;
//var v : Vector4;
function Start () {
LevelCreation(); //Uses functions in Level to make rooms.
//LevelCreation or ANY function from Level do not touch the variables that have problems linking.
}
EDITOR //The messiest of the messy, I apologize.
MODEL EDITOR
LIST EDITOR
AddModelList RemoveModelList change the size of the array.
function AddModelList(mainType : ModelList[]) :ModelList[]{ //Adds a new room type to the array.
var newType = new ModelList[mainType.length + 1];
for (i = 0 ; i < mainType.length ; ++i){
//Set mainType to newType
newType[i] = mainType[i];
}
newType[newType.length - 1] = main.DuplicateList();
return newType;
}//addmodel
function RemoveModelList(mainType : ModelList[], numb : int) :ModelList[]{ //Removes the selected room type from the array
//Until number is hit this is normal.
//When number is hit, we treat the next number (so i stays same)
if (mainType.length == 1){
Debug.Log("CANT REMOVE 0");
return mainType;
}
var newType = new ModelList[mainType.length - 1];
for (i = 0 ; i < numb ; ++i){
//Remove numb from array, bring down.
newType[i] = mainType[i];
}
for (i = i ; i < newType.length ; ++i){
//Remove numb from array, bring down.
newType[i] = mainType[i + 1];
}
// newType[newType.length ] = mainType[mainType.length -1].DuplicateType();
return newType;
}//removemodels
AddModel RemoveModel changes the size of the array for invidual ModelList variables.
function AddModel(mainType : Model[]) :Model[]{ //Adds a new room type to the array.
var levelVar = GameObject.Find("p_MAIN").GetComponent("GeneratingDummy");
var newType = new Model[mainType.length + 1];
for (i = 0 ; i < mainType.length ; ++i){
//Set mainType to newType
newType[i] = mainType[i];
}
//newType[newType.length - 1] = main.DuplicateModel();
newType[newType.length - 1] = levelVar.mainLevel.Models[indexPopup];
return newType;
}//addmodel
function RemoveModel(mainType : Model[], numb : int) :Model[]{ //Removes the selected room type from the array
//Until number is hit this is normal.
//When number is hit, we treat the next number (so i stays same)
if (mainType.length == 1){
Debug.Log("CANT REMOVE 0");
return mainType;
}
var newType = new Model[mainType.length - 1];
for (i = 0 ; i < numb ; ++i){
//Remove numb from array, bring down.
newType[i] = mainType[i];
}
for (i = i ; i < newType.length ; ++i){
//Remove numb from array, bring down.
newType[i] = mainType[i + 1];
}
// newType[newType.length ] = mainType[mainType.length -1].DuplicateType();
return newType;
}//removemodels
So to answer your question, I’m not doing anything special.
I’m literally doing varA = varB.
newType[newType.length - 1] = levelVar.mainLevel.Models[indexPopup]; //I want newType to point to levelVar, and to always copy it.
Edit: Feel free to move this to scripting, just realized it was in GUI.