c# - error CS0246: The type or namespace name `CardBoard' could not be found. Are you missing a using directive or an assembly reference?
I have been trying make a c# script that can change the cardboard camera to other cardboard camera, like when a character choose a chair, he teleport to cardboard camera on this chair: Basically I just want switch cardboard camera for another cardboard camera.
Copiler Errors:
teste1.cs(39,41): error CS0246: The type or namespace name `CardBoard' could not be found. Are you missing a using directive or an assembly reference?
This is c# script that I use:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class teste1 : MonoBehaviour {
public GameObject[] CamInicial = new GameObject[59]; // inicialização da camera
public GameObject[] CamNext = new GameObject[59]; // camera para a qual se vai fazer switch
int n; // id da camera
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
RaycastHit hit;
if (Physics.Raycast(hit.transform.position, transform.forward, out hit))
{
if (CamNext[n] != null)
{
switchCameras(n);
}
}
}
private void switchCameras(int keyNum)
{
for (int i = 0; i < CamNext.Length + 1; i++)
{
if (CamNext[i] != null && keyNum != i)
{
// turn camera off
CamNext[i].GetComponent<CardBoard>().enabled = false;
}
else {
// turn camera on
CamNext[i].GetComponent<CardBoard>().enabled = true;
}
}
}
}
My question is: Why CardBoard could not be found?
Location of Cameras:
I whant switch CardBoardMain to CardBoardAdapter, with a C# Script, what is that I failed in my script?
Answer by M-Hanssen · Apr 18, 2016 at 10:02 AM
Probably the problem is that you don't "Use" the namespace where the "CardBoard" is in.
Check out the Cardboard.cs file and look up in which namespace it is in. Then include this namespace inside your "teste1" script:
using <Cardboard namespace>;
If I use this, can I change CardBoard$$anonymous$$ain To CardBoardAdapter ?
I don't understand your question, maybe you can rephrase it or be more clear what you want to do?
I have 2 CardBoard Cameras, main and Adapter, my first person controler have main, and I see all my airplain with CardBoard$$anonymous$$ain, but I whant sit a character on sit of airplane, so I put a CardBoardAdapter in one sit and now I want click on it and move my perspective to CardBoardAdapter.
How can I do it? $$anonymous$$y script revolve my problem or I need make other one ?
Your answer
Follow this Question
Related Questions
How to include speed trigger creation option in this script. 0 Answers
Need help to put together 2 scripts 0 Answers
Recording Players voice in Unity using VR buttons. 0 Answers
Vr hand rotation tracking,Vr hand tracking 0 Answers
I want my script to wait 2 seconds before continue in a condition, in update, using C# 2 Answers