75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using GCSeries.Core.Input;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function
|
|
*******************************************************************************/
|
|
namespace ZXK.LouDiXvMuNiu
|
|
{
|
|
public class AutoRotCtrl : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private float _rotSpeed = 180.0f;
|
|
#if VR
|
|
bool isEnter = false;
|
|
private void Awake()
|
|
{
|
|
var zStylus = UIRoot.Instance.vrRoot.transform.Find("ZStylus").GetComponent<ZStylus>();
|
|
zStylus.OnObjectEntered.AddListener(VROnEnter);
|
|
zStylus.OnObjectExited.AddListener(VROnExit);
|
|
zStylus.OnClick.AddListener(VROnClick);
|
|
var zMouse = UIRoot.Instance.vrRoot.transform.Find("ZMouse").GetComponent<ZMouse>();
|
|
zMouse.OnObjectEntered.AddListener(VROnEnter);
|
|
zMouse.OnObjectExited.AddListener(VROnExit);
|
|
zMouse.OnClick.AddListener(VROnClick);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (isEnter)
|
|
{
|
|
transform.Rotate(Vector3.forward * Time.deltaTime * _rotSpeed);
|
|
}
|
|
}
|
|
|
|
private void VROnClick(ZPointer arg0, int arg1, GameObject arg2)
|
|
{
|
|
|
|
}
|
|
|
|
private void VROnExit(ZPointer arg0, GameObject arg1)
|
|
{
|
|
if (arg1==gameObject)
|
|
{
|
|
isEnter = false;
|
|
}
|
|
}
|
|
|
|
private void VROnEnter(ZPointer arg0, GameObject arg1)
|
|
{
|
|
if (arg1 == gameObject)
|
|
{
|
|
isEnter = true;
|
|
}
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
var zStylus = UIRoot.Instance.vrRoot.transform.Find("ZStylus").GetComponent<ZStylus>();
|
|
zStylus.OnObjectEntered.RemoveListener(VROnEnter);
|
|
zStylus.OnObjectExited.RemoveListener(VROnExit);
|
|
zStylus.OnClick.RemoveListener(VROnClick);
|
|
var zMouse = UIRoot.Instance.vrRoot.transform.Find("ZMouse").GetComponent<ZMouse>();
|
|
zMouse.OnObjectEntered.RemoveListener(VROnEnter);
|
|
zMouse.OnObjectExited.RemoveListener(VROnExit);
|
|
zMouse.OnClick.RemoveListener(VROnClick);
|
|
}
|
|
#endif
|
|
private void OnMouseOver()
|
|
{
|
|
transform.Rotate(Vector3.forward * Time.deltaTime * _rotSpeed);
|
|
}
|
|
}
|
|
} |