2019-10-07 10:29:02 -04:00
|
|
|
|
using System;
|
2019-03-28 14:13:39 -04:00
|
|
|
|
using UnityEngine;
|
2019-10-07 10:29:02 -04:00
|
|
|
|
using UnityEngine.EventSystems;
|
2019-03-28 14:13:39 -04:00
|
|
|
|
|
2019-10-07 10:29:02 -04:00
|
|
|
|
public class Rotate : MonoBehaviour, IEventSystemHandler
|
2019-03-28 14:13:39 -04:00
|
|
|
|
{
|
|
|
|
|
[SerializeField]
|
|
|
|
|
Vector3 RotateAmount;
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2019-10-07 10:29:02 -04:00
|
|
|
|
RotateAmount = new Vector3(0, 0, 0);
|
2019-03-28 14:13:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
gameObject.transform.Rotate(RotateAmount * Time.deltaTime * 10);
|
2019-10-07 10:29:02 -04:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Input.touchCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (Input.GetTouch(i).phase.Equals(TouchPhase.Began))
|
|
|
|
|
{
|
|
|
|
|
var hit = new RaycastHit();
|
|
|
|
|
|
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
|
|
|
|
|
|
|
|
|
|
if (Physics.Raycast(ray, out hit))
|
|
|
|
|
{
|
|
|
|
|
// This method is used to send data to Flutter
|
|
|
|
|
UnityMessageManager.Instance.SendMessageToFlutter("The cube feels touched.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This method is called from Flutter
|
|
|
|
|
public void SetRotationSpeed(String message)
|
|
|
|
|
{
|
|
|
|
|
float value = float.Parse(message);
|
|
|
|
|
RotateAmount = new Vector3(value, value, value);
|
2019-03-28 14:13:39 -04:00
|
|
|
|
}
|
|
|
|
|
}
|