示例#1
0
        private static void UMAFinished(UMAData thisUMAData)
        {
            HumanoidStructure human = GetHumanoid(thisUMAData.gameObject.name);

            AttachmentPoints points = thisUMAData.gameObject.AddComponent <AttachmentPoints>();

            BuildUMAAttachments(thisUMAData, human, points);
        }
示例#2
0
        //private static void AddAttachment
        public static void BuildUMAAttachments(UMAData thisUMAData, HumanoidStructure human, AttachmentPoints aPoints)
        {
            if (aPoints == null)
            {
                // get the attachment points component
                aPoints = thisUMAData.gameObject.GetComponent <AttachmentPoints>();
                if (aPoints == null)
                {
                    Debug.LogError("UMAElements.HumanoidBuilder.BuildUMAAttachments: Could not find AttachmentPoints script on UMA");
                    return;
                }
            }

            // remove all current attachments
            for (int i = 1; i < aPoints.Points.Length; i++)
            {
                int childcount = aPoints.Points[i].childCount;
                for (int c = childcount - 1; c >= 0; c--)
                {
                    GameObject.Destroy(aPoints.Points[i].GetChild(c).gameObject);
                }
            }

            // iterate through the list of attachments and see what we need to add
            for (int i = 0; i < human.Attachments.Count; i++)
            {
                // what position is this attachment in?
                int position = (int)human.Attachments[i].element.attachmentDefaultPos;
                if (human.Attachments[i].attachmentIsActive)
                {
                    position = (int)human.Attachments[i].element.attachmentActivePos;
                }

                // instantiate the prefab
                GameObject attachment = GameObject.Instantiate(human.Attachments[i].element.prefabItem) as GameObject;
                attachment.name                    = human.Attachments[i].element.prefabItem.name;
                attachment.transform.parent        = aPoints.Points[position];
                attachment.transform.localPosition = Vector3.zero;
                attachment.transform.localRotation = Quaternion.Euler(Vector3.zero);
            }
        }