Click here to Skip to main content
15,850,750 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(24,29): error CS1061: 'Text' does not contain a definition for 'T' and no accessible extension method 'T' accepting a first argument of type 'Text' could be found (are you missing a using directive or an assembly reference?)

What I have tried:

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;
Updated 4-Aug-21 15:05pm
Richard MacCutchan 4-Aug-21 12:06pm    
This is your third question on this same issue. I would suggest going to the Unity documentation and checking to see how to do it.

Share this answer
The code creates an object instance of camSwitchButton that is defined as type <text>.
public Text camSwitchButton

The code is attempting to set a property of type 'T' on the camSwitchButton instance of a <text> object with this statement
camSwitchButton.T = objects[m_CurrentActiveObject].name

The error message is telling you that there is no 'T' property on the <text> object.

What is the class definition for <text>? That's the object that needs to have the property or method named 'T'.
Share this answer
Member 15309599 4-Aug-21 11:33am    
so what should I do now ? I am new in this field .
James Walsh Jr 4-Aug-21 17:04pm    
Add the property 'T' to your class definition of 'Text'. It would probably help to see what the class 'Text' is in your code.
Member 15309599 4-Aug-21 22:55pm    
please say me steps how to do it . Because I am very new for this and i am not finding that on any of search engine . Please help
Member 15309599 4-Aug-21 23:27pm    
How to add PROPERTY T ?

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

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