예제 #1
0
        public void MountWeaponAttachment(GameObject attachment, GameObject weapon, WeaponPartLocation location)
        {
            if (attachment != null && weapon != null)
            {
                if (weapon.GetComponent <TransformCache>() == null)
                {
                    BoneTool.CacheTransform(weapon);
                }
                if (attachment.GetComponent <TransformCache>() == null)
                {
                    BoneTool.CacheTransform(attachment);
                }

                if (_attachmentLocator.ContainsKey(location))
                {
                    var anchor = FindChildBoneFromCache(attachment, BoneName.AttachmentLocator, false);
                    var target = FindChildBoneFromCache(weapon, _attachmentLocator[location], false);
                    FixedObj2Bones(attachment, anchor, target);
                }
                else
                {
                    _logger.WarnFormat("Wrong Attachment Location: {0}", location);
                }
            }
        }
예제 #2
0
        public static void CacheTransform(GameObject obj)
        {
            var cache = obj.GetComponent <TransformCache>();

            if (cache == null)
            {
                cache = obj.AddComponentUncheckRequireAndDisallowMulti <TransformCache>();
                BoneTool.CacheTransform(obj, cache);
            }
        }