hi!
first of all, i started using unity about two weeks ago tops, and i have been tackling down all kind of stuff with the mighty help of the chat channel and this forum (together with the good reference)
well, i have a scene with lots of cameras, that i might edit now and then in 3d studio max.
every time i import the cameras i will have to select them and add the components:
-camera
-gui layer
-skybox
-smooth lookat
then set the smooth lookat to look at the dummy named as the camera but ending in .Target
(asset name example: camera01.Target)
well. to do that with 3 or 4 cams might not be that much work, but i have more than 30. and animation changes or adding cameras will mean everything back again.
my plan was to do a script that runs trhough the adding component things, just creating 2 arrays, one with cameras and one with the targets.
once i add the components to the cams then the targets get set.
after a few hours, here it is:
notes:
-Malabar is the name of the company i work for
-my name is Martin Berisso
-and the skybox was always the same, so it didnt need to be set in this script, but in render settings.
// this script gets the "camaras" object that is the father to FBXimported cameras (camaras.fbx)
// upon import, those cameras are only gameObjects with transform.
// if a component "camera" is added, they look someplace not right, thats why the lookat script gets added
@MenuItem ("Component/Malabar/Cameras/Asign and Set Components")
static function Target_asign () {
// all childs of the "camaras" object:
var todas_las_camaras : Array= new Array();
// filtered out the Dummies and targets:
var camaras_main : Array = new Array();
//only the camera´s targets (always contain ".Target" in the name):
var camaras_target : Array = new Array();
var cam_padre : Transform;
cam_padre = GameObject.Find("camaras").transform;
// fills the arrays:
for (var child : Transform in cam_padre) {
todas_las_camaras.Add (child);
}
for(i=0 ; i<todas_las_camaras.length; i++){
if(!(todas_las_camaras[i].name.Contains("Dummy"))){
if(todas_las_camaras[i].name.Contains(".Target")){
camaras_target.Add (todas_las_camaras[i]);
} else{
camaras_main.Add (todas_las_camaras[i]);
}
}
}
// adds all the components needed. skybox will be set at render settings this time.
for(i=0; i<camaras_main.length; i++){
camaras_main[i].gameObject.AddComponent ("Camera");
camaras_main[i].gameObject.AddComponent ("GUILayer");
camaras_main[i].gameObject.AddComponent ("SmoothLookAt");
var this_cam_lookat : SmoothLookAt;
this_cam_lookat = camaras_main[i].gameObject.GetComponent (SmoothLookAt);
this_cam_lookat.damping = 0;
this_cam_lookat.smooth = false;
this_cam_lookat.target = camaras_target[i]; //this is a transform array
}
}