using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine.UI;
using UnityEngine.Events;
using UnityEngine.EventSystems;
///
/// 游戏中所有UI脚本必须显示继承
///
public class GameBehavior : MonoBehaviour
{
///
/// OnEnable 后 进入回调
///
public System.Action enterAc = null;
///
/// 参数
///
protected object param = null;
///
/// 设置参数
///
/// 参数
public void SetParameter(object parameter)
{
param = parameter;
}
///
/// 获取参数
///
/// 返回参数
public object GetParameter()
{
return this.param;
}
public virtual void registListeners()
{
//LogHelper.Log("registListeners");
}
public virtual void distroyListeners()
{
//LogHelper.Log("distroyListeners");
}
public virtual void OnDestroy()
{
distroyListeners();
}
public virtual void OnEnable()
{
//BaseRefresh();
}
public virtual void OnDisable()
{
distroyListeners();
}
public virtual void BaseRefresh()
{
registListeners();
if (enterAc != null)
{
enterAc(this.gameObject);
}
}
///
/// 查节点
///
/// 泛型
/// 查询对象
/// 查询结果
static public T FindInParents(GameObject go) where T : Component
{
if (go == null)
{
return null;
}
var comp = go.GetComponent();
if (comp != null)
{
return comp;
}
Transform t = go.transform.parent;
while (t != null && comp == null)
{
comp = t.gameObject.GetComponent();
t = t.parent;
}
return comp;
}
}