using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TFramework
{
    [Serializable]
    public class Behaviour : MonoBehaviour
    {
        [SerializeField, HideInInspector]
        private string m_id;

        public string ID{ 
        get => m_id = string.IsNullOrEmpty(m_id) ? gameObject.name + "_" + long.Parse(DateTime.Now.ToString("yyyyMMddhhmmss")).ToString("X") : m_id;
            protected set => m_id = value;
        } 

        public virtual void Start()
        {

        }

        /// <summary>
        /// 重置ID 
        /// </summary>
        public void ResetID()=> ID = gameObject.name + "_" + long.Parse(DateTime.Now.ToString("yyyyMMddhhmmss")).ToString("X");

        /// <summary>
        /// 复制
        /// </summary>
        public void CopyButtonEvent() => GUIUtility.systemCopyBuffer = ID;


        #region 通用
        /// <summary>
        /// 获取子物体
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public Transform GetChild(int index) => transform.childCount > 0 ? transform.GetChild(index) : null;

        /// <summary>
        /// 获取gameObject名字
        /// </summary>
        public string ObjName
        {
            get => gameObject.name;
            set => gameObject.name = value;
        }
        #endregion
    }
}
