Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
THIS ERROR KEEPS COMING .
Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(13,16): error CS0246: The type or namespace name 'text' could not be found (are you missing a using directive or an assembly reference?)

What I have tried:

THIS IS MY SCRIPT .

using UnityEngine;
using System.Collections;
using UnityEngine.UI;



#pragma warning disable 618
namespace UnityStandardAssets.utility
{
    public class SimpleActivatorMenu 
    {
        
        public text camSwitchButton ;
        public GameObject[] objects;


        private int m_CurrentActiveObject;


        private void OnEnable(){
        
            // active object starts from first in array
            m_CurrentActiveObject = 0;
            camSwitchButton.T = objects[m_CurrentActiveObject].name;
        }


        public void NextCamera()
        {
            int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;

            for (int i = 0; i < objects.Length; i++)
            {
                objects[i].SetActive(i == nextactiveobject);
            }

            m_CurrentActiveObject = nextactiveobject;
            camSwitchButton.T = objects[m_CurrentActiveObject].name;
             
        }
    }
}
Posted
Updated 3-Aug-21 5:36am

1 solution

Quote:
C#
public text camSwitchButton ;
This line causes the error. You have declared a field whose type is a custom class called text, but that class does not exist.

Perhaps you meant Text? Remember that C# is case-sensitive.

If Text doesn't exist either, then you're going to have to go back to where you got that code from and find the missing class. If it's not there, then find a more reliable source to learn from.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900