天津23维预案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

93 lines
2.8 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AX.MessageSystem;
using System;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using AX.TrackRecord;
public class GuanChaDianSetCtrl : MonoBehaviour
{
private GameObject selectedGcs;
public List<Vector3> GuanChaDians = new List<Vector3>();
private bool isOn;
private GameObject ResetButton;
private GameObject sureButton;
private RaycastHit hit;//射线
private Ray ray;
private LayerMask ground_layerMask = -1;
private int dropDownIndex;
// Use this for initialization
void Start()
{
MessageDispatcher.AddListener("BANGDINGGCS", BangDingGuanCs);
ResetButton = transform.Find("ResetButton").gameObject;
ResetButton.GetComponent<Button>().onClick.AddListener(ResetGCD);
sureButton = transform.Find("sureButton").gameObject;
sureButton.GetComponent<Button>().onClick.AddListener(SureGCDSet);
transform.Find("closeButton").GetComponent<Button>().onClick.AddListener(CloseWindow);
}
private void CloseWindow()
{
MessageDispatcher.SendMessage("CLOSE", (object)this.name, "CUBE");
}
private void BangDingGuanCs(IMessage obj)
{
selectedGcs = (GameObject)obj.Data;
GuanChaDians = selectedGcs.GetComponent<GuanChaShaoCtrl>().PosList;
}
private void ResetGCD()
{
GuanChaDians.Clear();
selectedGcs.GetComponent<GuanChaShaoCtrl>().index = 0;
selectedGcs.GetComponent<GuanChaShaoCtrl>().flag = false;
}
private void SureGCDSet()
{
selectedGcs.GetComponent<GuanChaShaoCtrl>().flag = true;
dropDownIndex = transform.Find("Dropdown").GetComponent<Dropdown>().value;
selectedGcs.GetComponent<GuanChaShaoCtrl>().value = int.Parse(transform.Find("Dropdown").GetComponent<Dropdown>().options[dropDownIndex].text);
MessageDispatcher.SendMessage("CLOSE", (object)transform.name, "CUBE");
if (RecordManager.Instance.IsRecording)
{
TrackRecordHelpClass.RecordEditGCS_SSRYEvent(selectedGcs);
}
}
// Update is called once per frame
void Update()
{
isOn = transform.Find("Toggle").GetComponent<Toggle>().isOn;
if (isOn)
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, Mathf.Infinity, ground_layerMask) && Input.GetMouseButtonDown(0) &&
!EventSystem.current.IsPointerOverGameObject())
{
GuanChaDians.Add(hit.point);
}
}
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("BANGDINGGCS", BangDingGuanCs);
ResetButton.GetComponent<Button>().onClick.RemoveListener(ResetGCD);
sureButton.GetComponent<Button>().onClick.RemoveListener(SureGCDSet);
}
}