using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EmployeeController : MonoBehaviour {
string name;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
this is whole code, for string name says: hides inherited member use keyword new if hiding was intentional.
Why does it do this, i dont even know what inherited member means here.
The MonoBehaviour class contains a string member called ‘name’ already which your derived class inherits. It’s telling you this because you’ve declared a member with that same name.
yeah i know that, fixed it but OCD kind of kicks and knowing i cant use variable “name” makes me uncomfortable,
is there some list of variables i cant use or something? how to enable usage of variable name other than new
Seems that you need to learn about inheritance. There’s a link in my OP for the MonoBehaviour docs, which lists all the members and inherited members. For your OCD you can omit the new keyword and disable the warning using #pragma warning but it would benefit you to learn about inherited members.
what you actually mean by OP i checked your profile and there are 2 links, one to your AppyNation webstie where are your games and otheris your page i guess which has your portfolio.
Yes, it’s the list of members of the type you inherited from (members including fields/variables, properties, methods).
In this case MonoBehaviour:
Everything on that page (with exception of the Messages), are members already defined on MonoBehaviour. Avoid defining new members with the same names.
Technically there’s some others that are undocumented, because Unity has obsoleted them. If you are using a full fledge IDE like Visual Studio, you can highlight MonoBehaviour in your code, right click, and select ‘goto definition’. This will bring you to the MonoBehaviour definition, and it’ll list all members, including those obsoleted.
If you’re using Visual Studio, let Intellisense do the work for you.
In a function, begin typing “this.na…” and it’ll pop up in intellisense. If it’s there, it’s already in use.
Or put the cursor on “Monobehaviour” and hit F12 to “Go to definition”, and it’ll show you the class members and methods. Also note that “Monobehaviour” itself derives from “Behaviour” which reserves “enabled”, and so on.