Files
MI-38/Heli_with_panels/Assets/Scripts/Handle2.cs
2022-07-04 13:15:35 +03:00

67 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
//using Debug = UnityEngine.Debug;
public class Handle2 : MonoBehaviour, IPointerDownHandler
{
public GameObject handle_on;
public GameObject handle_off;
// Start is called before the first frame update
void Start()
{
handle_off.SetActive(true);
handle_on.SetActive(false);
}
// Update is called once per frame
//void Update()
//{
/* Vector2 CurMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonUp(0))
{
//Для работы Raycast необходимо, чтоб объект имел компонент Collider
//В rayHit мы занесем результат выполнения команды Raycast
//там будет либо null, если raycast никого не задел, либо первый
//объект, стоящий на пути мышки (какой объект будет первым
//решает его положение Z в мировом пространстве)
RaycastHit2D rayHit = Physics2D.Raycast(CurMousePos, Vector2.zero);
if (rayHit.transform !=null)
{
Debug.Log("Selected object: "+ rayHit.transform.name);
// handle_on.SetActive(true);
}
} */
//}
public void OnPointerDown(PointerEventData eventData)
{
Vector2 CurMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D rayHit = Physics2D.Raycast(CurMousePos, Vector2.zero);
if (rayHit.transform !=null)
{
Debug.Log("Selected object: "+ rayHit.transform.name);
}
}
/* void OnMouseDown()
{
print("handle_off click");
handle_off.SetActive(false);
handle_on.SetActive(true);
} */
}