第一次提交
This commit is contained in:
69
Assets/Scripts/UnUse/UISafeAreaItem.cs
Normal file
69
Assets/Scripts/UnUse/UISafeAreaItem.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISafeAreaItem : MonoBehaviour
|
||||
{
|
||||
public InputField txtPos; //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtRadius; //<2F>뾶
|
||||
|
||||
public Button btnDel; //ɾ<><C9BE>
|
||||
public int itemIdx;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
AddInputNameClickEvent(txtPos);
|
||||
btnDel.onClick.AddListener(RemoveSelf);
|
||||
itemIdx = 0;
|
||||
}
|
||||
|
||||
private void AddInputNameClickEvent(InputField input) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Awake<6B>е<EFBFBD><D0B5><EFBFBD>
|
||||
{
|
||||
var eventTrigger = input.gameObject.AddComponent<EventTrigger>();
|
||||
UnityAction<BaseEventData> selectEvent = OnInputFieldClicked;
|
||||
EventTrigger.Entry onClick = new EventTrigger.Entry()
|
||||
{
|
||||
eventID = EventTriggerType.PointerClick
|
||||
};
|
||||
|
||||
onClick.callback.AddListener(selectEvent);
|
||||
eventTrigger.triggers.Add(onClick);
|
||||
}
|
||||
|
||||
private void OnInputFieldClicked(BaseEventData data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtRadius.text))
|
||||
return;
|
||||
|
||||
//UIWindow.Instance.uiSafeAreasPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
||||
//MapManager.Instance.SetCurSafeCenterPoint(itemIdx, Convert.ToInt32(txtRadius.text));
|
||||
//MapManager.Instance.SetEditCellType(MapManager.EditCellType.SafeArea);
|
||||
}
|
||||
|
||||
private void RemoveSelf()
|
||||
{
|
||||
DestroyImmediate(gameObject);
|
||||
//MapManager.Instance.RemoveSafeCenterPoint(itemIdx);
|
||||
}
|
||||
|
||||
public bool CheckValid()
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtPos.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtRadius.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ȫ<EFBFBD><C8AB><EFBFBD>뾶");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UnUse/UISafeAreaItem.cs.meta
Normal file
11
Assets/Scripts/UnUse/UISafeAreaItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b5fc24e47683e34580cead804a38fb6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Scripts/UnUse/UISafeAreasPanel.cs
Normal file
53
Assets/Scripts/UnUse/UISafeAreasPanel.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISafeAreasPanel : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public InputField curActiveInput;
|
||||
|
||||
public Transform itemParent;
|
||||
public Button btnAdd;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
btnAdd.onClick.AddListener(AddItem);
|
||||
}
|
||||
|
||||
void AddItem()
|
||||
{
|
||||
Object obj = Resources.Load("Prefabs/safeAreaItem");
|
||||
if (obj == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("safeAreaItem.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(obj) as GameObject; ;
|
||||
go.transform.SetParent(itemParent, false);
|
||||
UISafeAreaItem item = go.GetComponent<UISafeAreaItem>();
|
||||
item.itemIdx = itemParent.childCount;
|
||||
}
|
||||
|
||||
public void AddItem(Vector2Int pos, int radius)
|
||||
{
|
||||
Object obj = Resources.Load("Prefabs/safeAreaItem");
|
||||
if (obj == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("safeAreaItem.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(obj) as GameObject; ;
|
||||
go.transform.SetParent(itemParent, false);
|
||||
UISafeAreaItem item = go.GetComponent<UISafeAreaItem>();
|
||||
item.itemIdx = itemParent.childCount;
|
||||
//MapManager.Instance.SetCurSafeCenterPoint(item.itemIdx, radius);
|
||||
item.txtPos.text = $"{pos.x},{pos.y}";
|
||||
item.txtRadius.text = radius.ToString();
|
||||
//MapManager.Instance.CreateSpecialPoint(pos.x, pos.y, MapManager.EditCellType.SafeArea);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UnUse/UISafeAreasPanel.cs.meta
Normal file
11
Assets/Scripts/UnUse/UISafeAreasPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31cb1c0df337e034c8b72185a59e8b8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user