mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 02:25:38 +03:00
04.07.2022
This commit is contained in:
67
Heli_with_panels/Assets/Scripts/Handle2.cs
Normal file
67
Heli_with_panels/Assets/Scripts/Handle2.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
//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);
|
||||
|
||||
} */
|
||||
}
|
||||
Reference in New Issue
Block a user