- Home /
How to make a "Camera Rig Manager" that turns off the other 5 cameras not in use?
Hello I am new to Unity and scripting and need some guidance.
I am currently trying to make a guided tour that allows to see how visual impaired sees the world. It is actually impossible right now with this technology to simulate. But im am making the tour for a architect class and they will experience it through Oculus Go. Already made something and made it work. But I want to change how you navigate inside the spheres. And I see now that it would be nice with some more C# knowledge.
I using the Unity Documentation to make this, but get this error.
Assets/Scripts/SetActiveCameraRigA.cs(76,39): error CS1061: Type UnityEngine.GameObject' does not contain a definition for
enabled' and no extension method enabled' of type
UnityEngine.GameObject' could be found. Are you missing an assembly reference?
And i made a Google Doc to show with pictures and code.
Can anyone help me? I would be so happy for any pointers from anyone!
using UnityEngine;
using System.Collections;
public class SetActiveCameraRig : MonoBehaviour
{
public GameObject CameraRigA_Normal;
public GameObject CameraRigB_Cataract;
public GameObject CameraRigC_Glaucoma;
public GameObject CameraRigD_RetinitisPigmentosa;
public GameObject CameraRigE_DiabeticRetinopathy;
public GameObject CameraRigF_MaculaDegeneration;
//
public void NormalVision()
{
CameraRigA_Normal.enabled = true;
CameraRigB_Cataract.enabled = false;
CameraRigC_Glaucoma.enabled = false;
CameraRigD_RetinitisPigmentosa.enabled = false;
CameraRigE_DiabeticRetinopathy.enabled = false;
CameraRigF_MaculaDegeneration.enabled = false;
}
//
public void Cataract()
{
CameraRigA_Normal.enabled = false;
CameraRigB_Cataract.enabled = true;
CameraRigC_Glaucoma.enabled = false;
CameraRigD_RetinitisPigmentosa.enabled = false;
CameraRigE_DiabeticRetinopathy.enabled = false;
CameraRigF_MaculaDegeneration.enabled = false;
}
//
public void Glaucoma()
{
CameraRigA_Normal.enabled = false;
CameraRigB_Cataract.enabled = false;
CameraRigC_Glaucoma.enabled = true;
CameraRigD_RetinitisPigmentosa.enabled = false;
CameraRigE_DiabeticRetinopathy.enabled = false;
CameraRigF_MaculaDegeneration.enabled = false;
}
//
public void RetinitisPigmentosa()
{
CameraRigA_Normal.enabled = false;
CameraRigB_Cataract.enabled = false;
CameraRigC_Glaucoma.enabled = false;
CameraRigD_RetinitisPigmentosa.enabled = true;
CameraRigE_DiabeticRetinopathy.enabled = false;
CameraRigF_MaculaDegeneration.enabled = false;
}
//
public void DiabeticRetinopathy()
{
CameraRigA_Normal.enabled = false;
CameraRigB_Cataract.enabled = false;
CameraRigC_Glaucoma.enabled = false;
CameraRigD_RetinitisPigmentosa.enabled = false;
CameraRigE_DiabeticRetinopathy.enabled = true;
CameraRigF_MaculaDegeneration.enabled = false;
}
//
public void MaculaDegeneration()
{
CameraRigA_Normal.enabled = false;
CameraRigB_Cataract.enabled = false;
CameraRigC_Glaucoma.enabled = false;
CameraRigD_RetinitisPigmentosa.enabled = false;
CameraRigE_DiabeticRetinopathy.enabled = false;
CameraRigF_MaculaDegeneration.enabled = true;
}
}
Answer by axcersory · Oct 17, 2018 at 12:37 PM
change .enabled to SetActive(false) / SetActive(true)
example : CameraRigF_MaculaDegeneration.SetActive(false);
Answer by uuiarkmedvr · Oct 17, 2018 at 04:00 PM
Did some changes but still stuck. No Errors and Warnings this time.
Now the problem is to actually manage to switch between the different CameraRig's.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetActiveCameraRig : MonoBehaviour
{
public GameObject CameraRigA_Normal;
public GameObject CameraRigB_Cataract;
public GameObject CameraRigC_Glaucoma;
public GameObject CameraRigD_RetinitisPigmentosa;
public GameObject CameraRigE_DiabeticRetinopathy;
public GameObject CameraRigF_MaculaDegeneration;
// Update is called once per frame
public void Update()
{
if (CameraRigA_Normal == true)
{
CameraRigB_Cataract.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
CameraRigF_MaculaDegeneration.SetActive(false);
}
else if (CameraRigB_Cataract == true)
{
CameraRigA_Normal.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
CameraRigF_MaculaDegeneration.SetActive(false);
}
else if (CameraRigC_Glaucoma == true)
{
CameraRigA_Normal.SetActive(false);
CameraRigB_Cataract.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
CameraRigF_MaculaDegeneration.SetActive(false);
}
else if (CameraRigD_RetinitisPigmentosa == true)
{
CameraRigA_Normal.SetActive(false);
CameraRigB_Cataract.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
CameraRigF_MaculaDegeneration.SetActive(false);
}
else if (CameraRigE_DiabeticRetinopathy == true)
{
CameraRigA_Normal.SetActive(false);
CameraRigB_Cataract.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigF_MaculaDegeneration.SetActive(false);
}
else if (CameraRigF_MaculaDegeneration == true)
{
CameraRigA_Normal.SetActive(false);
CameraRigB_Cataract.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
}
}
}
@uuiarkmedvr $$anonymous$$aybe you can use an Input to switch between camera. Actually i dont know what are you going to do. And sorry for my bad english.
Example: If you press a key then switch the camera.
public void Update()
{
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Y))
{
CameraRigA_Normal.SetActive(true); // $$anonymous$$ake this true and else false.
CameraRigB_Cataract.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
CameraRigF_$$anonymous$$aculaDegeneration.SetActive(false);
}
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.U))
{
CameraRigB_Cataract.SetActive(true);//make this true and else false.
CameraRigA_Normal.SetActive(false);
CameraRigC_Glaucoma.SetActive(false);
CameraRigD_RetinitisPigmentosa.SetActive(false);
CameraRigE_DiabeticRetinopathy.SetActive(false);
CameraRigF_$$anonymous$$aculaDegeneration.SetActive(false);
}
}