Exemple #1
0
        /// <summary>
        /// 查找角色,武器,配件的关节请使用缓存版本的函数BoneMount.FindChildBoneFromCache
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="target"></param>
        /// <param name="ignoreMissing"></param>
        /// <returns></returns>
        /// <seealso cref="BoneMount.FindChildBoneFromCache"/>
        public static Transform FindChildBone(GameObject obj, string target, bool ignoreMissing = false)
        {
            if (obj != null && target != null)
            {
                var r = BoneTool.FindTransformFromCache(obj, target);

                if (r == null)
                {
                    _logger.InfoFormat("target:{0} is not cached!!!!", target);
                    r = obj.transform.FindTransformRecursive(target);
                }

                if (r == null && !ignoreMissing)
                {
                    _logger.DebugFormat("missing {0} in {1}", target, obj.name);
                }
                return(r);
            }
            else
            {
                _logger.DebugFormat("null object or null target in FindChildBone");
            }

            return(null);
        }
Exemple #2
0
        public static void CacheTransform(GameObject obj)
        {
            var cache = obj.GetComponent <TransformCache>();

            if (cache == null)
            {
                cache = obj.AddComponentUncheckRequireAndDisallowMulti <TransformCache>();
                BoneTool.CacheTransform(obj, cache);
            }
        }
Exemple #3
0
 private static void FindTarget(GameObject obj, string target, ref Transform r, bool containsUnActive = false)
 {
     CacheResults.Clear();
     obj.GetComponentsInChildren <TransformCache>(CacheResults);
     if (CacheResults.Count == 0)
     {
         _logger.DebugFormat("obj:{0} has no cache", obj);
     }
     foreach (TransformCache transformCache in CacheResults)
     {
         r = BoneTool.FindTransformFromCache(transformCache, target, containsUnActive);
         if (r != null)
         {
             break;
         }
     }
 }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="target"></param>
        /// <param name="containsAttach">是否包含子节点缓存</param>
        /// <param name="containsUnActive">是否包含UnActive的节点</param>
        /// <returns></returns>
        public static Transform FindChildBoneFromCache(GameObject obj, string target, bool containsAttach = true, bool containsUnActive = false)
        {
            Transform r = null;

            if (obj != null && target != null)
            {
                if (containsAttach)
                {
                    FindTarget(obj, target, ref r, containsUnActive);
                }
                else if (obj.GetComponent <TransformCache>() == null)
                {
                    FindTarget(obj, target, ref r, containsUnActive);
                }
                else
                {
                    r = BoneTool.FindTransformFromCache(obj, target, containsUnActive);
                }
                return(r);
            }
            _logger.DebugFormat("null object or null target in FindChildBone");

            return(null);
        }