63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using QFramework;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XMLTool;
|
|
|
|
public class Point3DItem : MonoBehaviour
|
|
{
|
|
Point3DQuestion.Data data;
|
|
|
|
[SerializeField]
|
|
private float rotSpeed = 180.0f;
|
|
public void Init(Point3DQuestion.Data data)
|
|
{
|
|
this.data = data;
|
|
if (string.IsNullOrEmpty(data.name) == false)
|
|
{
|
|
gameObject.name = data.name;
|
|
}
|
|
if (string.IsNullOrEmpty(data.deviceName))
|
|
{
|
|
gameObject.transform.position = data.pos;
|
|
gameObject.transform.eulerAngles = data.rotate;
|
|
gameObject.transform.localScale = data.scale;
|
|
}
|
|
else
|
|
{
|
|
GameObject device = DeviceController.Instance.GetDeviceObj(data.deviceName);
|
|
gameObject.transform.parent = device.transform;
|
|
gameObject.transform.localPosition = Vector3.zero;
|
|
gameObject.transform.localEulerAngles = Vector3.zero;
|
|
gameObject.transform.localScale = Vector3.one;
|
|
|
|
|
|
}
|
|
rotSpeed = data.rotateSpeed;
|
|
TypeEventSystem.Global.Register<OnPoint3DQuestionDestroy>(OnObjDestroy).UnRegisterWhenGameObjectDestroyed(gameObject);
|
|
|
|
}
|
|
|
|
private void OnObjDestroy(OnPoint3DQuestionDestroy destroy)
|
|
{
|
|
GameObject.Destroy(gameObject);
|
|
}
|
|
|
|
private void OnMouseUpAsButton()
|
|
{
|
|
if (string.IsNullOrEmpty(data.clickEvent) == false)
|
|
{
|
|
StringEventSystem.Global.Send(data.clickEvent);
|
|
}
|
|
TypeEventSystem.Global.Send<OnPoint3DQuestionDestroy>();
|
|
}
|
|
|
|
private void OnMouseOver()
|
|
{
|
|
transform.Rotate(Vector3.forward * Time.deltaTime * rotSpeed);
|
|
}
|
|
|
|
|
|
}
|