protected void ApplyTemplate()
        {
            Undo.RegisterCompleteObjectUndo(this, "Apply Template");

            HumanTemplate humanTemplate = OpenHumanTemplate();

            if (humanTemplate == null)
            {
                return;
            }

            for (int i = 0; i < m_Bones.Length; i++)
            {
                string boneName = humanTemplate.Find(m_Bones[i].humanBoneName);
                if (boneName.Length > 0)
                {
                    Transform transform = modelBones.Keys.FirstOrDefault(f => AvatarMappingEditor.MatchName(f.name, boneName));
                    m_Bones[i].bone = transform;
                }
                else
                {
                    m_Bones[i].bone = null;
                }
                m_Bones[i].Serialize(m_HumanBoneArray);
            }

            ValidateMapping();
            SceneView.RepaintAll();
        }
Exemplo n.º 2
0
 public static int ShowBoneMapping(int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor)
 {
   GUILayout.BeginHorizontal();
   GUILayout.FlexibleSpace();
   if ((bool) ((Object) AvatarControl.styles.Silhouettes[shownBodyView].image))
   {
     Rect rect = GUILayoutUtility.GetRect(AvatarControl.styles.Silhouettes[shownBodyView], GUIStyle.none, new GUILayoutOption[1]{ GUILayout.MaxWidth((float) AvatarControl.styles.Silhouettes[shownBodyView].image.width) });
     AvatarControl.DrawBodyParts(rect, shownBodyView, bodyPartCallback);
     for (int i = 0; i < bones.Length; ++i)
       AvatarControl.DrawBone(shownBodyView, i, rect, bones[i], serializedObject, editor);
   }
   else
     GUILayout.Label("texture missing,\nfix me!");
   GUILayout.FlexibleSpace();
   GUILayout.EndHorizontal();
   Rect lastRect = GUILayoutUtility.GetLastRect();
   string[] strArray = new string[4]{ "Body", "Head", "Left Hand", "Right Hand" };
   lastRect.x += 5f;
   lastRect.width = 70f;
   lastRect.yMin = lastRect.yMax - 69f;
   lastRect.height = 16f;
   for (int index = 0; index < strArray.Length; ++index)
   {
     if (GUI.Toggle(lastRect, shownBodyView == index, strArray[index], EditorStyles.miniButton))
       shownBodyView = index;
     lastRect.y += 16f;
   }
   return shownBodyView;
 }
Exemplo n.º 3
0
 protected static void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor)
 {
     if (s_BonePositions[shownBodyView, i] != Vector2.zero)
     {
         Vector2 vector = s_BonePositions[shownBodyView, i];
         vector.y *= -1f;
         vector.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f));
         vector = rect.center + vector;
         int num = 0x13;
         Rect rect2 = new Rect(vector.x - (num * 0.5f), vector.y - (num * 0.5f), (float) num, (float) num);
         bone.BoneDotGUI(rect2, i, true, true, serializedObject, editor);
     }
 }
Exemplo n.º 4
0
 public static int ShowBoneMapping(int shownBodyView, BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor)
 {
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     if (styles.Silhouettes[shownBodyView].image != null)
     {
         GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth((float) styles.Silhouettes[shownBodyView].image.width) };
         Rect rect = GUILayoutUtility.GetRect(styles.Silhouettes[shownBodyView], GUIStyle.none, options);
         DrawBodyParts(rect, shownBodyView, bodyPartCallback);
         for (int j = 0; j < bones.Length; j++)
         {
             DrawBone(shownBodyView, j, rect, bones[j], serializedObject, editor);
         }
     }
     else
     {
         GUILayout.Label("texture missing,\nfix me!", new GUILayoutOption[0]);
     }
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     Rect lastRect = GUILayoutUtility.GetLastRect();
     string[] strArray = new string[] { "Body", "Head", "Left Hand", "Right Hand" };
     lastRect.x += 5f;
     lastRect.width = 70f;
     lastRect.yMin = lastRect.yMax - 69f;
     lastRect.height = 16f;
     for (int i = 0; i < strArray.Length; i++)
     {
         if (GUI.Toggle(lastRect, shownBodyView == i, strArray[i], EditorStyles.miniButton))
         {
             shownBodyView = i;
         }
         lastRect.y += 16f;
     }
     return shownBodyView;
 }
Exemplo n.º 5
0
        protected void ApplyTemplate()
        {
            Undo.RegisterCompleteObjectUndo(this, "Apply Template");
            HumanTemplate humanTemplate = this.OpenHumanTemplate();

            if (humanTemplate == null)
            {
                return;
            }
            for (int i = 0; i < this.m_Bones.Length; i++)
            {
                string boneName = humanTemplate.Find(this.m_Bones[i].humanBoneName);
                if (boneName.Length > 0)
                {
                    Transform bone = base.modelBones.Keys.FirstOrDefault((Transform f) => AvatarMappingEditor.MatchName(f.name, boneName));
                    this.m_Bones[i].bone = bone;
                }
                else
                {
                    this.m_Bones[i].bone = null;
                }
                this.m_Bones[i].Serialize(base.serializedObject);
            }
            this.ValidateMapping();
            SceneView.RepaintAll();
        }
Exemplo n.º 6
0
        public static int ShowBoneMapping(int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if ((bool)((Object)AvatarControl.styles.Silhouettes[shownBodyView].image))
            {
                Rect rect = GUILayoutUtility.GetRect(AvatarControl.styles.Silhouettes[shownBodyView], GUIStyle.none, new GUILayoutOption[1] {
                    GUILayout.MaxWidth((float)AvatarControl.styles.Silhouettes[shownBodyView].image.width)
                });
                AvatarControl.DrawBodyParts(rect, shownBodyView, bodyPartCallback);
                for (int i = 0; i < bones.Length; ++i)
                {
                    AvatarControl.DrawBone(shownBodyView, i, rect, bones[i], serializedObject, editor);
                }
            }
            else
            {
                GUILayout.Label("texture missing,\nfix me!");
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            Rect lastRect = GUILayoutUtility.GetLastRect();

            string[] strArray = new string[4] {
                "Body", "Head", "Left Hand", "Right Hand"
            };
            lastRect.x     += 5f;
            lastRect.width  = 70f;
            lastRect.yMin   = lastRect.yMax - 69f;
            lastRect.height = 16f;
            for (int index = 0; index < strArray.Length; ++index)
            {
                if (GUI.Toggle(lastRect, shownBodyView == index, strArray[index], EditorStyles.miniButton))
                {
                    shownBodyView = index;
                }
                lastRect.y += 16f;
            }
            return(shownBodyView);
        }
Exemplo n.º 7
0
        protected static void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor)
        {
            if (AvatarControl.s_BonePositions[shownBodyView, i] == Vector2.zero)
            {
                return;
            }
            Vector2 bonePosition = AvatarControl.s_BonePositions[shownBodyView, i];

            bonePosition.y *= -1f;
            bonePosition.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f));
            Vector2 vector2 = rect.center + bonePosition;
            int     num     = 19;
            Rect    rect1   = new Rect(vector2.x - (float)num * 0.5f, vector2.y - (float)num * 0.5f, (float)num, (float)num);

            bone.BoneDotGUI(rect1, i, true, true, serializedObject, editor);
        }
Exemplo n.º 8
0
 protected static void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor)
 {
   if (AvatarControl.s_BonePositions[shownBodyView, i] == Vector2.zero)
     return;
   Vector2 bonePosition = AvatarControl.s_BonePositions[shownBodyView, i];
   bonePosition.y *= -1f;
   bonePosition.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f));
   Vector2 vector2 = rect.center + bonePosition;
   int num = 19;
   Rect rect1 = new Rect(vector2.x - (float) num * 0.5f, vector2.y - (float) num * 0.5f, (float) num, (float) num);
   bone.BoneDotGUI(rect1, i, true, true, serializedObject, editor);
 }
Exemplo n.º 9
0
 protected static void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor)
 {
     if (s_BonePositions[shownBodyView, i] != Vector2.zero)
     {
         Vector2 vector = s_BonePositions[shownBodyView, i];
         vector.y *= -1f;
         vector.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f));
         vector = rect.center + vector;
         int  num   = 0x13;
         Rect rect2 = new Rect(vector.x - (num * 0.5f), vector.y - (num * 0.5f), (float)num, (float)num);
         bone.BoneDotGUI(rect2, i, true, true, serializedObject, editor);
     }
 }
Exemplo n.º 10
0
        public static int ShowBoneMapping(int shownBodyView, BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor)
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            if (styles.Silhouettes[shownBodyView].image != null)
            {
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth((float)styles.Silhouettes[shownBodyView].image.width) };
                Rect rect = GUILayoutUtility.GetRect(styles.Silhouettes[shownBodyView], GUIStyle.none, options);
                DrawBodyParts(rect, shownBodyView, bodyPartCallback);
                for (int j = 0; j < bones.Length; j++)
                {
                    DrawBone(shownBodyView, j, rect, bones[j], serializedObject, editor);
                }
            }
            else
            {
                GUILayout.Label("texture missing,\nfix me!", new GUILayoutOption[0]);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            Rect lastRect = GUILayoutUtility.GetLastRect();

            string[] strArray = new string[] { "Body", "Head", "Left Hand", "Right Hand" };
            lastRect.x     += 5f;
            lastRect.width  = 70f;
            lastRect.yMin   = lastRect.yMax - 69f;
            lastRect.height = 16f;
            for (int i = 0; i < strArray.Length; i++)
            {
                if (GUI.Toggle(lastRect, shownBodyView == i, strArray[i], EditorStyles.miniButton))
                {
                    shownBodyView = i;
                }
                lastRect.y += 16f;
            }
            return(shownBodyView);
        }
Exemplo n.º 11
0
        static protected void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor)
        {
            if (s_BonePositions[shownBodyView, i] == Vector2.zero)
            {
                return;
            }

            Vector2 pos = s_BonePositions[shownBodyView, i];

            pos.y *= -1; // because higher values should be up
            pos.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f));
            pos = rect.center + pos;
            int  kIconSize = AvatarSetupTool.BoneWrapper.kIconSize;
            Rect r         = new Rect(pos.x - kIconSize * 0.5f, pos.y - kIconSize * 0.5f, kIconSize, kIconSize);

            bone.BoneDotGUI(r, r, i, true, true, true, serializedObject, editor);
        }
Exemplo n.º 12
0
        static public int ShowBoneMapping(int shownBodyView, BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor)
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();

                if (styles.Silhouettes[shownBodyView].image)
                {
                    Rect rect = GUILayoutUtility.GetRect(styles.Silhouettes[shownBodyView], GUIStyle.none, GUILayout.MaxWidth(styles.Silhouettes[shownBodyView].image.width));
                    DrawBodyParts(rect, shownBodyView, bodyPartCallback);

                    for (int i = 0; i < bones.Length; i++)
                    {
                        DrawBone(shownBodyView, i, rect, bones[i], serializedObject, editor);
                    }
                }
                else
                {
                    GUILayout.Label("texture missing,\nfix me!");
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            // Body view buttons
            Rect        buttonsRect  = GUILayoutUtility.GetLastRect();
            const float buttonHeight = 18;

            string[] labels = new string[] { "Body", "Head", "Left Hand", "Right Hand" };
            buttonsRect.x     += 5;
            buttonsRect.width  = 80;
            buttonsRect.yMin   = buttonsRect.yMax - (buttonHeight * 4 + 5);
            buttonsRect.height = buttonHeight;
            for (int i = 0; i < labels.Length; i++)
            {
                if (GUI.Toggle(buttonsRect, shownBodyView == i, labels[i], EditorStyles.miniButton))
                {
                    shownBodyView = i;
                }
                buttonsRect.y += buttonHeight;
            }

            return(shownBodyView);
        }