public static bool vCheckAndCache_Components_InChildren <T>(this GameObject obj, ref T[] components, System.Func <bool> callBack) where T : Component
 {
     if (components == null || components.Length <= 0)
     {
         components = obj.GetComponentsInChildren <T>();
         if (components.Length <= 0)
         {
             Debug.LogFormat("物件 {0} 以及 其子物件没有所需要部件 : {1}", obj.name, typeof(T).ToString());
             return(false);
         }
         else
         {
             if (callBack())
             {
                 return(true);
             }
             else
             {
                 Debug.LogFormat("反调函数 {0} 发生错误", callBack.ToString());
                 Debug.LogWarningFormat("反调函数 {0} 发生错误", callBack.ToString());
                 return(false);
             }
         }
     }
     return(true);
 }
        public static bool vCheckAndCache_RenderMat(this GameObject _obj, ref Renderer _renderer, ref Material _mat, System.Func <bool> callBack)
        {
            if (_renderer != null && _mat != null)
            {
                return(true);
            }
            else
            {
                _renderer = _obj.GetComponent <Renderer>();
                if (_renderer == null)
                {
                    Debug.LogWarningFormat("GameObject ::<0> don't have a Mesh Renderer", _obj.name);
                    return(false);
                }

                _mat = _renderer.sharedMaterial;

                if (_mat == null)
                {
                    Debug.LogWarningFormat("GameObject ::<0> don't have a Material", _obj.name);
                    return(false);
                }

                if (callBack())
                {
                    return(true);
                }
                else
                {
                    Debug.LogFormat("反调函数 {0} 发生错误", callBack.ToString());
                    return(false);
                }
            }
        }
        private void TestDelegateTypes()
        {
            string method_name = "ProcessDelegateTypes";

            System.Reflection.MethodInfo method_info  = sample_class_type.GetMethod(method_name);
            System.Func <int, bool>      is_leap_year = System.DateTime.IsLeapYear;
            method_info.Invoke(sample_class_instance, new System.Object[] { is_leap_year });
            Assert.IsTrue(Logger.CallLogger.LastLog.Contains(sample_class_name + "::" + method_name));
            Assert.IsTrue(Logger.CallLogger.LastLog.Contains(is_leap_year.ToString()));
        }
 public static bool vCheckAndCache_Component <T>(this GameObject obj, ref T component, System.Func <bool> callback) where T : Component
 {
     if (component == null)
     {
         component = obj.GetComponent <T>();
         if (component == null)
         {
             Debug.LogFormat("物件 {0} 没有所需要部件 : {1}", obj.name, typeof(T).ToString());
             return(false);
         }
         if (callback())
         {
             return(true);
         }
         else
         {
             Debug.LogWarningFormat("反调函数 {0} 发生错误", callback.ToString());
         }
     }
     return(true);
 }