using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Playeer : MonoBehaviour
{
public GameObject UIElement;
public float RayLenght;
public Text UIText;
private void Update()
{
if (Input.GetKeyDown(KeyCode.E) && UIElement.activeSelf == false)
{
Ray _ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
RaycastHit _hit;
if (Physics.Raycast(_ray, out _hit, RayLenght))
{
if (_hit.collider.gameObject.GetComponent())
{
UIElement.SetActive(true);
UIText.text = _hit.collider.gameObject.GetComponent().Text;
}
}
}
else if (Input.GetKeyDown(KeyCode.E) && UIElement.activeSelf == true ||
Input.GetKeyDown(KeyCode.Escape) && UIElement.activeSelf == true)
{
UIElement.SetActive(false);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Playeer : MonoBehaviour
{
public GameObject UIElement;
public float RayLenght;
public Text UIText;
private void Update()
{
if (Input.GetKeyDown(KeyCode.E) && UIElement.activeSelf == false)
{
Ray _ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
RaycastHit _hit;
if (Physics.Raycast(_ray, out _hit, RayLenght))
{
if (_hit.collider.gameObject.GetComponent())
{
UIElement.SetActive(true);
UIText.text = _hit.collider.gameObject.GetComponent().Text;
}
}
}
else if (Input.GetKeyDown(KeyCode.E) && UIElement.activeSelf == true || Input.GetKeyDown(KeyCode.Escape) && UIElement.activeSelf == true)
{
UIElement.SetActive(false);
}
}
}
Can't add script
Can't add script component 'Playeer' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
вот пример скрипта
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Playeer : MonoBehaviour;
{
public GameObject UIElement;
public float RayLenght;
public Text UIText;
private void Update()
{
if (Input.GetKeyDown(KeyCode.E) && UIElement.activeSelf == false)
{
Ray _ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
RaycastHit _hit;
if (Physics.Raycast(_ray, out _hit, RayLenght))
{
if (_hit.collider.gameObject.GetComponent<NoteText>())
{
UIElement.SetActive(true);
UIText.text = _hit.collider.gameObject.GetComponent<NoteText>().Text;
}
}
}
else if (Input.GetKeyDown(KeyCode.E) && UIElement.activeSelf == true || Input.GetKeyDown(KeyCode.Escape) && UIElement.activeSelf == true)
{
UIElement.SetActive(false);
}
}
}
Помогите пожалуйста