zoukankan      html  css  js  c++  java
  • 1

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using UnityEngine;

    namespace Game.UI
    {
        public class UIItemWidget : MonoBehaviour
        {
            ResourceSet mResources;
            bool mHasDestroy = false;
            public bool hasDestroy { get { return mHasDestroy; } }

            public virtual ResourceSet resources
            {
                get
                {
                    if (mResources == null)
                    {
                        mResources = new ResourceSet();
                    }
                    return mResources;
                }
            }

            //public bool hasDestroy { get { return resources.hasDestroy; } }

            //protected virtual void Awake()
            //{
            //}
            protected virtual void OnDestroy()
            {
                if(mResources!=null)
                    mResources.Destroy();
                mHasDestroy = true;
                //Debug.Log(ToString() + ".OnDestroy()");
            }
            public virtual void Destroy()
            {
                if (mResources != null)
                    mResources.Destroy();
                mHasDestroy = true;
            }
            public void ClearInstanceAndResource()
            {
                if (mResources != null)
                    mResources.ClearAllInstanceAndResource();
            }

            //protected void _RegResource( string _path , BaseLoadInfo resObj)
            //{
            //    resources._RegResource(_path ,resObj);
            //}

            //protected void _RegInstance(UnityEngine.Object instObj)
            //{
            //    resources._RegInstance(instObj);
            //}

            public void DeleteResource(ResourceSet.ResourceInfo resObj)
            {
                resources.DeleteResource(resObj);
            }

            public bool DeleteInstance(UnityEngine.Object instObj, bool immedia = false)
            {
                return resources.DeleteInstance(instObj,immedia);
            }

            /// <summary>
            /// 添加一个界面图集
            /// </summary>
            /// <param name="atlas">图集名</param>
            /// <param name="img">图素名</param>
            /// <param name="obj">控件对象</param>

            public ResourceSet.ResourceInfo AddResourceEx(string res)
            {
                return resources.AddResourceEx(res);
            }
            public UnityEngine.Object AddResource(string res)
            {
                return resources.AddResource(res);
            }
            public void AddResourceAsync(string res, ResourceSet.OnLoadResEnd onLoadEnd)
            {
                resources.AddResourceAsync(res, onLoadEnd);
            }
            public UnityEngine.Object AddInstance(string widgetName)
            {
                return resources.AddInstance(widgetName);
            }
            public BaseLoadInfo AddInstanceAsync(string widgetName, ResourceSet.OnObjectLoadEnd onLoadEnd)
            {
                return resources.AddInstanceAsync(widgetName, onLoadEnd);
            }
            public GameObject CreateGameObject(string name, Transform parent)
            {
                return resources.AddGameInstanceAsSubObject(name, parent);
            }
            public GameObject AddGameInstance(string name, Transform parent)
            {
                return resources.AddGameInstanceAsSubObject(name, parent);
            }
            public BaseLoadInfo AddGameInstanceAsync(string name, Transform parent, ResourceSet.OnGameObjectLoadEnd onLoadEnd)
            {
                return resources.AddGameInstanceAsSubObjectAsync(name, parent, onLoadEnd);
            }

            public void DestroyTrans(Transform tran,bool immedia=false)
            {
                if (null == tran)
                {
                    return;
                }
                for (int i = tran.childCount - 1; i >= 0; i--)
                {
                    DeleteInstance(tran.GetChild(i).gameObject,immedia);
                }
            }
        }
    }

  • 相关阅读:
    监听Windows消息
    把遇到过的对.Net线程的一些问题和误解集中起来和大家分享,也希望大家能一起补充,热烈欢迎讨论(转)
    推荐一个好工具:P/Invoke Interop Assistant (转)
    其它操作EDM的方式 (转载)
    DotNet(C#)自定义运行时窗体设计器 一
    通过监听Windows消息对复合控件进行整体控制(C#)一
    DotNet(C#)自定义运行时窗体设计器Runtime FormDesigner(转载)
    C# 枚举中的位运算
    Linux下cat 命令
    小端字节序与大端字节序
  • 原文地址:https://www.cnblogs.com/rexzhao/p/7278953.html
Copyright © 2011-2022 走看看