using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SecondNodeWindow : MonoBehaviour { private SecondNodeObject nodeObject; public InputField nodeName; public InputField nodeDetail; public Button okButton; public Button cancelButton; public string oldNodeName; // Use this for initialization void Start() { okButton.onClick.AddListener(OkFun); cancelButton.onClick.AddListener(CancelFun); } // Update is called once per frame void Update() { } public void SetWindow(SecondNodeObject node) { nodeObject = node; nodeName.text = nodeObject.nodeName; nodeDetail.text = nodeObject.nodeDetail; } private void OkFun() { oldNodeName = nodeObject.nodeName;//先记录修改前的节点名字,为修改后对数据文件名称的修改做准备,因为数据文件是以节点名字命名的,囧。 nodeObject.nodeName = nodeName.text.Trim(); nodeObject.nodeDetail = nodeDetail.text.Trim(); if (nodeObject.nodeID == -1) { transform.parent.GetComponent().AddNode(nodeObject); } else { transform.parent.GetComponent().EditorNode(nodeObject); } } private void CancelFun() { gameObject.SetActive(false); if (nodeObject.nodeID == -1) { ResourceLoadWindow.Instance.LoadTipWindow("是否放弃此条记录?", DeleteRecord, ContinueRecord); } } private void DeleteRecord() { transform.parent.GetComponent().DeleteRecord(); } private void ContinueRecord() { transform.parent.GetComponent().ContinueRecord(); } }