- Home /
Error code CS0246
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ButtonControl : IPointerEnterHandler, IPointerExitHandler
{
private GameObject childText = null; // or make public and drag
void Start(){
Text text= GetComponentInChildren<Text>();
if (text != null)
{
childText = text.gameObject;
childText.SetActive(false);
}
}
public void OnPointerEnter(EventSystems.PointerEventData eventData)
{
childText.SetActive(true);
}
public void OnPointerExit(EventSystems.PointerEventData eventData)
{
childText.SetActive(false);
}
}
im using this script so that when i highlight the button it shows some text, but i keep getting error code CS0246. It says that 'EventSystems' could not be found and asks if im missing an assembly reference. i have searched this up but couldnt find anything that helped. they are mostly other scripts that dont relate to my game.
so, this function isnt so important but i would like it in my script. i got i from here: [1]: http://answers.unity3d.com/questions/1025135/how-to-make-text-appear-only-when-over-buttonhighl.html?_ga=2.174713378.182906120.1500506428-1905419412.1499251455 im very sorry for troubling everyone but i really need help because i am horrible at coding. Thanks
Answer by Zendist · Jul 17, 2017 at 11:26 PM
Remove EventSystems
from the function argument types:
public void OnPointerEnter(PointerEventData eventData)
{
childText.SetActive(true);
}
public void OnPointerExit(PointerEventData eventData)
{
childText.SetActive(false);
}
Answer by tushi · Jul 18, 2017 at 07:44 AM
i fixed it up and then i got some more errors. if fixed them and then i got this: Assets/Shake.cs(13,48): error CS1525: Unexpected symbol `)'
i currently have this script: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI;
public class Shake : MonoBehaviour {
public class ButtonControl : IPointerEnterHandler, IPointerExitHandler
{
private GameObject childText = null; // or make public and drag
void Start(){
Text text= GetComponentInChildren<"Text(3)">();
if (text != null)
{
childText = text.gameObject;
childText.SetActive(false);
}
}
public void OnPointerEnter(PointerEventData eventData)
{
childText.SetActive(true);
}
public void OnPointerExit(PointerEventData eventData)
{
childText.SetActive(false);
}
}
}
i got rid of the problem but then i got another one, and if these problems continue, i will end up with nothing. PLEASE HELP!!! Thanks. :)
Answer by ZeN12 · Jul 18, 2017 at 07:52 AM
Check in your scene if you have an object EventSystem with script attached EventSystem. It requires to be in order to work with uGUI.
i dont know what that is :( i am only new to coding and unity. and whats an EventSystem? i got this script from another question and i dont understand c sharp as well as java.
right now it says that there is an unexpected symbol (error code CS1525) and that is ')'. the code looks fine.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class Shake : $$anonymous$$onoBehaviour {
public class ButtonControl : IPointerEnterHandler, IPointerExitHandler
{
private GameObject childText = null; // or make public and drag
void Start(){
Text text= GetComponentInChildren<"Text(3)">();
if (text != null)
{
childText = text.gameObject;
childText.SetActive(false);
}
}
public void OnPointerEnter(PointerEventData eventData)
{
childText.SetActive(true);
}
public void OnPointerExit(PointerEventData eventData)
{
childText.SetActive(false);
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612130516im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Photon and the tutorial on cjrgaming.com 1 Answer
[Win app] CS0246 & CS0234 :BindingFlags and Cryptography 2 Answers
Missing assembly references when importing/upgrading DOTS stack 1 Answer
What does "The type or namespace name x could not be found" mean? 5 Answers
itween imports into compile errors 1 Answer