Ejemplo n.º 1
0
        void Reset()
        {
            try
            {
                _boneGroups = new List <BoneGroup>(4);

                for (int i = 0; i < transform.childCount; i++)
                {
                    var child = transform.GetChild(i);
                    if (child.gameObject.name != "Editor Tools")
                    {
                        var grounp = new BoneGroup();
                        grounp.bonePivot  = child;
                        grounp.maleModel  = child.FindChild("MaleModel").gameObject;
                        grounp.femalModel = child.FindChild("FemaleModel").gameObject;
                        _boneGroups.Add(grounp);
                    }
                }
            }
            catch
            {
                UnityEditor.EditorUtility.DisplayDialog("Error", "层级异常", "OK");
            }
        }
Ejemplo n.º 2
0
        public void Reset()
        {
            _boneGroups = new List <BoneGroup>();
            BoneGroup group = new BoneGroup();

            string[]  names = BoneConfig.instance.boneNames;
            Transform model = null, ragdoll = null;

            for (int i = 0; i < transform.childCount; i++)
            {
                string name = transform.GetChild(i).name;

                if ((name.Contains("model") || name.Contains("Model")) && !name.Contains("defencemodel"))
                {
                    if (model == null)
                    {
                        model = transform.GetChild(i);
                    }
                    else
                    {
                        Debug.LogError("Model Error: " + gameObject.name);
                        return;
                    }
                }

                if (name.Contains("ragdoll") || name.Contains("Ragdoll"))
                {
                    if (ragdoll == null)
                    {
                        ragdoll = transform.GetChild(i);
                    }
                    else
                    {
                        Debug.LogError("Ragdoll Error: " + gameObject.name);
                        return;
                    }
                }
            }

            if (model == null || ragdoll == null)
            {
                Debug.LogError("Prefab Error: " + gameObject.name);
                return;
            }

            for (int i = 0; i < names.Length; i++)
            {
                group.name = names[i];

                group.model = (Transform)model.TraverseHierarchy
                              (
                    (Transform t, int d) =>
                {
                    if (t.gameObject.name == group.name)
                    {
                        return(t);
                    }
                    return(null);
                }
                              );

                group.ragdoll = (Transform)ragdoll.TraverseHierarchy
                                (
                    (Transform t, int d) =>
                {
                    if (t.gameObject.name == group.name)
                    {
                        return(t);
                    }
                    return(null);
                }
                                );

                int c = 0;
                if (group.model)
                {
                    c++;
                }
                if (group.ragdoll)
                {
                    c++;
                }

                if (c == 1)
                {
                    Debug.LogError(gameObject.name + " Bone Error: " + group.name);
                    return;
                }

                if (c == 2)
                {
                    _boneGroups.Add(group);
                }
            }
        }