C
C#•2w ago
Lukas

ERROR CS0111

Assets\Scrips\SelectionManager.cs(9,18): error CS0111: Type 'SelectionManager' already defines a member called 'Start' with the same parameter types What am i doing wrong?
using UnityEngine;

public class SelectionManager : MonoBehaviour
{

public GameObject interaction_Info_UI;
Text interaction_text;

private void Start()
{
interaction_text = interaction_Info_UI.GetComponent<Text>();
}

void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
var selectionTransform = hit.transform;

if (selectionTransform.GetComponent<InteractableObject>())
{
interaction_text.text = selectionTransform.GetComponent<InteractableObject>().GetItemName();
interaction_Info_UI.SetActive(true);
}
else
{
interaction_Info_UI.SetActive(false);
}

}
}
}
using UnityEngine;

public class SelectionManager : MonoBehaviour
{

public GameObject interaction_Info_UI;
Text interaction_text;

private void Start()
{
interaction_text = interaction_Info_UI.GetComponent<Text>();
}

void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
var selectionTransform = hit.transform;

if (selectionTransform.GetComponent<InteractableObject>())
{
interaction_text.text = selectionTransform.GetComponent<InteractableObject>().GetItemName();
interaction_Info_UI.SetActive(true);
}
else
{
interaction_Info_UI.SetActive(false);
}

}
}
}
17 Replies
MODiX
MODiX•2w ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Angius
Angius•2w ago
Maybe MonoBehaviour already defines Start() and you're hiding it instead of overwriting or something>
Gamma_Draconis
Gamma_Draconis•2w ago
Something is defining Start() already and the question is what. The class definition you've given isn't partial, which means it isn't either a source generator or another code file... Does the unity toolchain do any kind of compile time code generation?
SelfLess
SelfLess•2w ago
clear last build ,ctrl+f search for 'start' term occourance in ur document..correct it..run..
Lukas
LukasOP•2w ago
so now i did get the other error, just wanna say im new to coding 🙂 Assets\Scrips\SelectionManager.cs(7,5): error CS0246: The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?) Could anyone maybe tell me whats wrong here, tried 4 hours last night 🙂
Angius
Angius•2w ago
What is Text? What namespace is it in? Import that namespace If you have VS set up correctly to work with Unity, you should be able to use quick fixes to auto-import it
Lukas
LukasOP•2w ago
how does it auto import it?
Angius
Angius•2w ago
Lukas
LukasOP•2w ago
Thanks, after installing the unity update it deleted my files in the project, any way getting them back?
Angius
Angius•2w ago
Unity update should not have done anything of the sort If it somehow did... restore the files from your remote Git repo Or some other backup You do have backups, right?
Lukas
LukasOP•2w ago
i didnt make some but i did build the game and ran it can i take the files from there?
Angius
Angius•2w ago
No You can't unbake a cake
Lukas
LukasOP•2w ago
isnt there a way getting it back? it didnt remove the project only the scripts and gameobjects and so but when i open visual studio i can find the scripts for the game
Angius
Angius•2w ago
I don't have much experience with Unity, alas Try asking in $unity server
Angius
Angius•2w ago
If the code still physically exists though, it should be fine Probably a matter of Unity not picking it up somehow
Lukas
LukasOP•2w ago
its wierd

Did you find this page helpful?