Right now, I have a scene with a main camera focused on a huge complex organization of blocks. I have wired the camera to move and zoom into the one of the blocks but inactivating the other objects when it does so (So the other blocks do not show when zooming in). Now, I want to move my camera back the previous scene with the complexity of the blocks and render all the blocks as active once more. However, for some reason, when I go back to where the main camera was initially (zoomed out), the objects are still inactive. I’m not sure what’s wrong with my code? Here’s part of the script for changing views to where the objects were located.
using UnityEngine;
using System.Collections;
public class BackButton : MonoBehaviour {
public Camera mainCam;
public GameObject[] Objects;
void OnGUI () {
// Make a background box
GUI.Box(new Rect(10,10,250,200), "Menu");
if(GUI.Button (new Rect (30,40,200,70), "Back to Blocks with stripes ")) {
print ("You clicked the button!");
mainCam.transform.position= new Vector3(-.13f, 0.87f, -8);
Camera.main.orthographicSize = 0.4f;
}
if (GUI.Button (new Rect (30,120,200,70), "Back to the Block Complex")) {
print ("You clicked the button!");
Objects = GameObject.FindGameObjectsWithTag("blocks");
for (int i=0; i<Objects.Length; i++) {
Objects*.active=true;*
-
}*
-
mainCam.transform.position= new Vector3(0, 1.1f, -8);*
-
Camera.main.orthographicSize = 1.3f;*
-
}*
-
}*
-
}*
I tried to find all the objects tagged with blocks and setting them back to active (after I have set them inactive after mousedown on one of the blocks) but it doesn’t seem to work.
When I comment out this part, the same thing happens. So I think this part of the script isn’t doing it’s job:
Objects = GameObject.FindGameObjectsWithTag(“blocks”);
for (int i=0; i<Objects.Length; i++) {
Objects*.active=true;*
}