79 lines
2.0 KiB
C#
79 lines
2.0 KiB
C#
using Games.LogicObj;
|
|
using UnityEngine;
|
|
|
|
public class DropBoardManager : MonoBehaviour
|
|
{
|
|
public static DropBoardManager Instacne { get; private set; }
|
|
public GameObject _DropBoardPrefab = null;
|
|
public GameObject _DropNameBoard;
|
|
|
|
private void Awake()
|
|
{
|
|
gameObject.name = "DropItemBoardRoot";
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
Instacne = this;
|
|
transform.rotation = Quaternion.Euler(Vector3.zero);
|
|
if (_DropNameBoard == null)
|
|
_DropNameBoard = GameObject.Find("UI Root/WorldUIRoot/DropItemNameBoard");
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instacne = null;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
|
|
}
|
|
|
|
public Obj_DropItem CreateDrop(Obj_DropItemData initData)
|
|
{
|
|
Obj_DropItem objDropItem = null;
|
|
GameObject dorpItem = GameObject.Instantiate(_DropBoardPrefab) as GameObject;
|
|
dorpItem.name = initData.m_ServerID.ToString();
|
|
if (null != dorpItem)
|
|
{
|
|
objDropItem = (Obj_DropItem)dorpItem.GetComponent<Obj_DropItem>();
|
|
if (!objDropItem)
|
|
{
|
|
objDropItem = (Obj_DropItem)dorpItem.AddComponent<Obj_DropItem>();
|
|
}
|
|
|
|
if (objDropItem && objDropItem.Init(initData))
|
|
{
|
|
objDropItem.CanLogic = true;
|
|
}
|
|
return objDropItem;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void ClearDropName()
|
|
{
|
|
if (_DropNameBoard != null)
|
|
{
|
|
var boardChilds = _DropNameBoard.GetComponentsInChildren<Transform>();
|
|
foreach (var child in boardChilds)
|
|
{
|
|
if (child.gameObject == _DropNameBoard)
|
|
continue;
|
|
|
|
GameObject.Destroy(child.gameObject);
|
|
}
|
|
}
|
|
|
|
var dropItems = GetComponentsInChildren<Transform>();
|
|
foreach (var child in dropItems)
|
|
{
|
|
if (child.gameObject == this.gameObject)
|
|
continue;
|
|
|
|
child.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|