internal override void OnEnable()
        {
            m_AnimationType       = serializedObject.FindProperty("m_AnimationType");
            m_AvatarSource        = serializedObject.FindProperty("m_LastHumanDescriptionAvatarSource");
            m_OptimizeGameObjects = serializedObject.FindProperty("m_OptimizeGameObjects");

            // Generic bone setup
            m_RootMotionBoneName     = serializedObject.FindProperty("m_HumanDescription.m_RootMotionBoneName");
            m_RootMotionBoneRotation = serializedObject.FindProperty("m_HumanDescription.m_RootMotionBoneRotation");

            m_ExposeTransformEditor = new ExposeTransformEditor();

            string[] transformPaths = singleImporter.transformPaths;
            m_RootMotionBoneList = new GUIContent[transformPaths.Length];
            for (int i = 0; i < transformPaths.Length; i++)
            {
                m_RootMotionBoneList[i] = new GUIContent(transformPaths[i]);
            }

            if (m_RootMotionBoneList.Length > 0)
            {
                m_RootMotionBoneList[0] = EditorGUIUtility.TrTextContent("None");
            }

            rootIndex = ArrayUtility.FindIndex(m_RootMotionBoneList, delegate(GUIContent content) { return(FileUtil.GetLastPathNameComponent(content.text) == m_RootMotionBoneName.stringValue); });
            rootIndex = rootIndex < 1 ? 0 : rootIndex;

            m_SrcHasExtraRoot = serializedObject.FindProperty("m_HasExtraRoot");
            m_DstHasExtraRoot = serializedObject.FindProperty("m_HumanDescription.m_HasExtraRoot");

            // Animation
            m_CopyAvatar = serializedObject.FindProperty("m_CopyAvatar");
            m_LegacyGenerateAnimations = serializedObject.FindProperty("m_LegacyGenerateAnimations");
            m_AnimationCompression     = serializedObject.FindProperty("m_AnimationCompression");

            m_RigImportErrors   = serializedObject.FindProperty("m_RigImportErrors");
            m_RigImportWarnings = serializedObject.FindProperty("m_RigImportWarnings");

            m_ExposeTransformEditor.OnEnable(singleImporter.transformPaths, serializedObject);

            m_CanMultiEditTransformList = CanMultiEditTransformList();

            // Check if avatar definition is same as the one it's copied from
            CheckIfAvatarCopyIsUpToDate();

            m_IsBiped            = false;
            m_BipedMappingReport = new List <string>();

            if (m_AnimationType.intValue == (int)ModelImporterAnimationType.Human)
            {
                GameObject go = assetTarget as GameObject;
                if (go != null)
                {
                    m_IsBiped = AvatarBipedMapper.IsBiped(go.transform, m_BipedMappingReport);
                }

                if (m_Avatar == null)
                {
                    ResetAvatar();
                }
            }
        }
        private SerializedNodeInfo FillNodeInfos()
        {
            var rootNode = new SerializedNodeInfo()
            {
                depth = -1, displayName = "", id = 0, children = new List <TreeViewItem>(0)
            };

            if (m_TransformMask == null || m_TransformMask.arraySize == 0)
            {
                return(rootNode);
            }

            var nodesCount          = m_TransformMask.arraySize;
            var nodeInfos           = new List <SerializedNodeInfo>(nodesCount);
            SerializedProperty prop = m_TransformMask.GetArrayElementAtIndex(0);

            prop.Next(false);
            Stack <string> depth       = new Stack <string>(nodesCount);
            string         currentPath = String.Empty;

            for (int i = 1; i < nodesCount; i++)
            {
                var newNode = new SerializedNodeInfo();
                newNode.id       = i;
                newNode.m_Path   = prop.FindPropertyRelative("m_Path");
                newNode.m_Weight = prop.FindPropertyRelative("m_Weight");

                var newPath = newNode.m_Path.stringValue;
                while (!string.IsNullOrEmpty(currentPath) && !newPath.StartsWith(currentPath + "/"))
                {
                    // we are in a new node, lets unstack until we reach the correct hierarchy
                    var oldParent = depth.Pop();
                    var index     = currentPath.LastIndexOf(oldParent);
                    if (index > 0)
                    {
                        index--;
                    }
                    currentPath = currentPath.Remove(index);
                }
                var nodeName = newPath;
                if (!string.IsNullOrEmpty(currentPath))
                {
                    nodeName = nodeName.Remove(0, currentPath.Length + 1);
                }

                if (m_CanImport)
                {
                    // in avatar mask inspector UI,everything is enabled.
                    newNode.m_State = SerializedNodeInfo.State.Enabled;
                }
                else if (humanTransforms != null)
                {
                    //  Enable only transforms that are not human. Human transforms in this case are handled by muscle curves and cannot be imported.
                    if (ArrayUtility.FindIndex(humanTransforms, s => newPath == s) == -1)
                    {
                        if (m_TransformPaths != null && ArrayUtility.FindIndex(m_TransformPaths, s => newPath == s) == -1)
                        {
                            newNode.m_State = SerializedNodeInfo.State.Invalid;
                        }
                        else
                        {
                            newNode.m_State = SerializedNodeInfo.State.Enabled;
                        }
                    }
                    else
                    {
                        newNode.m_State = SerializedNodeInfo.State.Disabled;
                    }
                }
                else if (m_TransformPaths != null && ArrayUtility.FindIndex(m_TransformPaths, s => newPath == s) == -1)
                {
                    // mask does not map to an existing hierarchy node. It's invalid.
                    newNode.m_State = SerializedNodeInfo.State.Invalid;
                }
                else
                {
                    newNode.m_State = SerializedNodeInfo.State.Enabled;
                }

                newNode.depth       = depth.Count;
                newNode.displayName = nodeName;
                depth.Push(nodeName);
                currentPath = newPath;
                nodeInfos.Add(newNode);
                prop.Next(false);
            }

            TreeViewUtility.SetChildParentReferences(nodeInfos.Cast <TreeViewItem>().ToList(), rootNode);
            return(rootNode);
        }
Exemplo n.º 3
0
 public void FillNodeInfos()
 {
     this.m_NodeInfos = new AvatarMaskInspector.NodeInfo[this.m_TransformMask.arraySize];
     if (this.m_TransformMask.arraySize != 0)
     {
         string[]           array = new string[this.m_TransformMask.arraySize];
         SerializedProperty arrayElementAtIndex = this.m_TransformMask.GetArrayElementAtIndex(0);
         arrayElementAtIndex.Next(false);
         for (int i = 1; i < this.m_NodeInfos.Length; i++)
         {
             this.m_NodeInfos[i].m_Path   = arrayElementAtIndex.FindPropertyRelative("m_Path");
             this.m_NodeInfos[i].m_Weight = arrayElementAtIndex.FindPropertyRelative("m_Weight");
             array[i] = this.m_NodeInfos[i].m_Path.stringValue;
             string fullPath = array[i];
             if (this.m_CanImport)
             {
                 this.m_NodeInfos[i].m_State = AvatarMaskInspector.NodeInfo.State.enabled;
             }
             else if (this.humanTransforms != null)
             {
                 if (ArrayUtility.FindIndex <string>(this.humanTransforms, (string s) => fullPath == s) == -1)
                 {
                     if (this.m_TransformPaths != null && ArrayUtility.FindIndex <string>(this.m_TransformPaths, (string s) => fullPath == s) == -1)
                     {
                         this.m_NodeInfos[i].m_State = AvatarMaskInspector.NodeInfo.State.invalid;
                     }
                     else
                     {
                         this.m_NodeInfos[i].m_State = AvatarMaskInspector.NodeInfo.State.enabled;
                     }
                 }
                 else
                 {
                     this.m_NodeInfos[i].m_State = AvatarMaskInspector.NodeInfo.State.disabled;
                 }
             }
             else if (this.m_TransformPaths != null && ArrayUtility.FindIndex <string>(this.m_TransformPaths, (string s) => fullPath == s) == -1)
             {
                 this.m_NodeInfos[i].m_State = AvatarMaskInspector.NodeInfo.State.invalid;
             }
             else
             {
                 this.m_NodeInfos[i].m_State = AvatarMaskInspector.NodeInfo.State.enabled;
             }
             this.m_NodeInfos[i].m_Expanded     = true;
             this.m_NodeInfos[i].m_ParentIndex  = -1;
             this.m_NodeInfos[i].m_ChildIndices = new List <int>();
             AvatarMaskInspector.NodeInfo[] arg_248_0_cp_0 = this.m_NodeInfos;
             int arg_248_0_cp_1 = i;
             int arg_248_1;
             if (i == 0)
             {
                 arg_248_1 = 0;
             }
             else
             {
                 arg_248_1 = fullPath.Count((char f) => f == '/');
             }
             arg_248_0_cp_0[arg_248_0_cp_1].m_Depth = arg_248_1;
             string text = "";
             int    num  = fullPath.LastIndexOf('/');
             if (num > 0)
             {
                 text = fullPath.Substring(0, num);
             }
             num = ((num != -1) ? (num + 1) : 0);
             this.m_NodeInfos[i].m_Name = fullPath.Substring(num);
             for (int j = 1; j < i; j++)
             {
                 string a = array[j];
                 if (text != "" && a == text)
                 {
                     this.m_NodeInfos[i].m_ParentIndex = j;
                     this.m_NodeInfos[j].m_ChildIndices.Add(i);
                 }
             }
             arrayElementAtIndex.Next(false);
         }
     }
 }
        internal override void OnEnable()
        {
            m_ClipAnimations = serializedObject.FindProperty("m_ClipAnimations");

            m_AnimationType            = serializedObject.FindProperty("m_AnimationType");
            m_LegacyGenerateAnimations = serializedObject.FindProperty("m_LegacyGenerateAnimations");

            // Animation
            m_ImportAnimation                = serializedObject.FindProperty("m_ImportAnimation");
            m_BakeSimulation                 = serializedObject.FindProperty("m_BakeSimulation");
            m_ResampleCurves                 = serializedObject.FindProperty("m_ResampleCurves");
            m_AnimationCompression           = serializedObject.FindProperty("m_AnimationCompression");
            m_AnimationRotationError         = serializedObject.FindProperty("m_AnimationRotationError");
            m_AnimationPositionError         = serializedObject.FindProperty("m_AnimationPositionError");
            m_AnimationScaleError            = serializedObject.FindProperty("m_AnimationScaleError");
            m_AnimationWrapMode              = serializedObject.FindProperty("m_AnimationWrapMode");
            m_ImportAnimatedCustomProperties = serializedObject.FindProperty("m_ImportAnimatedCustomProperties");
            m_ImportConstraints              = serializedObject.FindProperty("m_ImportConstraints");

            m_RigImportErrors                = serializedObject.FindProperty("m_RigImportErrors");
            m_RigImportWarnings              = serializedObject.FindProperty("m_RigImportWarnings");
            m_AnimationImportErrors          = serializedObject.FindProperty("m_AnimationImportErrors");
            m_AnimationImportWarnings        = serializedObject.FindProperty("m_AnimationImportWarnings");
            m_AnimationRetargetingWarnings   = serializedObject.FindProperty("m_AnimationRetargetingWarnings");
            m_AnimationDoRetargetingWarnings = serializedObject.FindProperty("m_AnimationDoRetargetingWarnings");

            if (serializedObject.isEditingMultipleObjects)
            {
                return;
            }

            // Find all serialized property before calling SetupDefaultClips
            if (m_ClipAnimations.arraySize == 0)
            {
                SetupDefaultClips();
            }

            selectedClipIndex = EditorPrefs.GetInt("ModelImporterClipEditor.ActiveClipIndex", 0);
            ValidateClipSelectionIndex();
            EditorPrefs.SetInt("ModelImporterClipEditor.ActiveClipIndex", selectedClipIndex);

            if (m_AnimationClipEditor != null && selectedClipIndex >= 0)
            {
                SyncClipEditor();
            }

            // Automatically select the first clip
            if (m_ClipAnimations.arraySize != 0)
            {
                SelectClip(selectedClipIndex);
            }

            string[] transformPaths = singleImporter.transformPaths;
            m_MotionNodeList = new GUIContent[transformPaths.Length + 1];

            m_MotionNodeList[0] = EditorGUIUtility.TrTextContent("<None>");

            for (int i = 0; i < transformPaths.Length; i++)
            {
                if (i == 0)
                {
                    m_MotionNodeList[1] = EditorGUIUtility.TrTextContent("<Root Transform>");
                }
                else
                {
                    m_MotionNodeList[i + 1] = new GUIContent(transformPaths[i]);
                }
            }

            m_MotionNodeName = serializedObject.FindProperty("m_MotionNodeName");
            motionNodeIndex  = ArrayUtility.FindIndex(m_MotionNodeList, delegate(GUIContent content) { return(content.text == m_MotionNodeName.stringValue); });
            motionNodeIndex  = motionNodeIndex < 1 ? 0 : motionNodeIndex;
        }
        private SerializedNodeInfo FillNodeInfos()
        {
            var rootNode = new SerializedNodeInfo()
            {
                depth = -1, displayName = "", id = 0, children = new List <TreeViewItem>(0)
            };

            if (m_TransformMask == null || m_TransformMask.arraySize == 0)
            {
                return(rootNode);
            }

            var nodesCount = m_TransformMask.arraySize;
            var nodeInfos  = new List <SerializedNodeInfo>(nodesCount);

            string[]           paths = new string[nodesCount];
            SerializedProperty prop  = m_TransformMask.GetArrayElementAtIndex(0);

            prop.Next(false);

            for (int i = 1; i < nodesCount; i++)
            {
                var newNode = new SerializedNodeInfo();
                newNode.id       = i;
                newNode.m_Path   = prop.FindPropertyRelative("m_Path");
                newNode.m_Weight = prop.FindPropertyRelative("m_Weight");

                paths[i] = newNode.m_Path.stringValue;
                string fullPath = paths[i];
                if (m_CanImport)
                {
                    // in avatar mask inspector UI,everything is enabled.
                    newNode.m_State = SerializedNodeInfo.State.Enabled;
                }
                else if (humanTransforms != null)
                {
                    //  Enable only transforms that are not human. Human transforms in this case are handled by muscle curves and cannot be imported.
                    if (ArrayUtility.FindIndex(humanTransforms, s => fullPath == s) == -1)
                    {
                        if (m_TransformPaths != null && ArrayUtility.FindIndex(m_TransformPaths, s => fullPath == s) == -1)
                        {
                            newNode.m_State = SerializedNodeInfo.State.Invalid;
                        }
                        else
                        {
                            newNode.m_State = SerializedNodeInfo.State.Enabled;
                        }
                    }
                    else
                    {
                        newNode.m_State = SerializedNodeInfo.State.Disabled;
                    }
                }
                else if (m_TransformPaths != null && ArrayUtility.FindIndex(m_TransformPaths, s => fullPath == s) == -1)
                {
                    // mask does not map to an existing hierarchy node. It's invalid.
                    newNode.m_State = SerializedNodeInfo.State.Invalid;
                }
                else
                {
                    newNode.m_State = SerializedNodeInfo.State.Enabled;
                }

                newNode.depth = i == 0 ? 0 : fullPath.Count(f => f == '/');

                int lastIndex = fullPath.LastIndexOf('/');
                lastIndex           = lastIndex == -1 ? 0 : lastIndex + 1;
                newNode.displayName = fullPath.Substring(lastIndex);

                nodeInfos.Add(newNode);
                prop.Next(false);
            }

            TreeViewUtility.SetChildParentReferences(nodeInfos.Cast <TreeViewItem>().ToList(), rootNode);
            return(rootNode);
        }
Exemplo n.º 6
0
 private void FillNodeInfos()
 {
     this.m_NodeInfos = new AvatarMaskInspector.NodeInfo[this.m_TransformMask.arraySize];
     for (int index1 = 1; index1 < this.m_NodeInfos.Length; ++index1)
     {
         // ISSUE: object of a compiler-generated type is created
         // ISSUE: variable of a compiler-generated type
         AvatarMaskInspector.\u003CFillNodeInfos\u003Ec__AnonStorey86 infosCAnonStorey86 = new AvatarMaskInspector.\u003CFillNodeInfos\u003Ec__AnonStorey86();
         this.m_NodeInfos[index1].m_Path   = this.m_TransformMask.GetArrayElementAtIndex(index1).FindPropertyRelative("m_Path");
         this.m_NodeInfos[index1].m_Weight = this.m_TransformMask.GetArrayElementAtIndex(index1).FindPropertyRelative("m_Weight");
         // ISSUE: reference to a compiler-generated field
         infosCAnonStorey86.fullPath = this.m_NodeInfos[index1].m_Path.stringValue;
         // ISSUE: reference to a compiler-generated method
         this.m_NodeInfos[index1].m_Enabled      = this.humanTransforms == null || ArrayUtility.FindIndex <string>(this.humanTransforms, new Predicate <string>(infosCAnonStorey86.\u003C\u003Em__146)) == -1;
         this.m_NodeInfos[index1].m_Expanded     = true;
         this.m_NodeInfos[index1].m_ParentIndex  = -1;
         this.m_NodeInfos[index1].m_ChildIndices = new List <int>();
         // ISSUE: reference to a compiler-generated field
         this.m_NodeInfos[index1].m_Depth = index1 != 0 ? infosCAnonStorey86.fullPath.Count <char>((Func <char, bool>)(f => (int)f == 47)) : 0;
         string str = string.Empty;
         // ISSUE: reference to a compiler-generated field
         int length = infosCAnonStorey86.fullPath.LastIndexOf('/');
         if (length > 0)
         {
             // ISSUE: reference to a compiler-generated field
             str = infosCAnonStorey86.fullPath.Substring(0, length);
         }
         int startIndex = length != -1 ? length + 1 : 0;
         // ISSUE: reference to a compiler-generated field
         this.m_NodeInfos[index1].m_Name = infosCAnonStorey86.fullPath.Substring(startIndex);
         int arraySize = this.m_TransformMask.arraySize;
         for (int index2 = 0; index2 < arraySize; ++index2)
         {
             string stringValue = this.m_TransformMask.GetArrayElementAtIndex(index2).FindPropertyRelative("m_Path").stringValue;
             if (str != string.Empty && stringValue == str)
             {
                 this.m_NodeInfos[index1].m_ParentIndex = index2;
             }
             // ISSUE: reference to a compiler-generated field
             if (stringValue.StartsWith(infosCAnonStorey86.fullPath) && stringValue.Count <char>((Func <char, bool>)(f => (int)f == 47)) == this.m_NodeInfos[index1].m_Depth + 1)
             {
                 this.m_NodeInfos[index1].m_ChildIndices.Add(index2);
             }
         }
     }
 }
Exemplo n.º 7
0
        public void FillNodeInfos()
        {
            m_NodeInfos = new NodeInfo[m_TransformMask.arraySize];
            if (m_TransformMask.arraySize == 0)
            {
                return;
            }

            string[] paths = new string[m_TransformMask.arraySize];

            SerializedProperty prop = m_TransformMask.GetArrayElementAtIndex(0);

            prop.Next(false);

            for (int i = 1; i < m_NodeInfos.Length; i++)
            {
                m_NodeInfos[i].m_Path   = prop.FindPropertyRelative("m_Path");
                m_NodeInfos[i].m_Weight = prop.FindPropertyRelative("m_Weight");

                paths[i] = m_NodeInfos[i].m_Path.stringValue;
                string fullPath = paths[i];
                if (m_CanImport)
                {
                    // in avatar mask inspector UI,everything is enabled.
                    m_NodeInfos[i].m_State = NodeInfo.State.enabled;
                }
                else if (humanTransforms != null)
                {
                    //  Enable only transforms that are not human. Human transforms in this case are handled by muscle curves and cannot be imported.
                    if (ArrayUtility.FindIndex(humanTransforms, s => fullPath == s) == -1)
                    {
                        if (m_TransformPaths != null && ArrayUtility.FindIndex(m_TransformPaths, s => fullPath == s) == -1)
                        {
                            m_NodeInfos[i].m_State = NodeInfo.State.invalid;
                        }
                        else
                        {
                            m_NodeInfos[i].m_State = NodeInfo.State.enabled;
                        }
                    }
                    else
                    {
                        m_NodeInfos[i].m_State = NodeInfo.State.disabled;
                    }
                }
                else if (m_TransformPaths != null && ArrayUtility.FindIndex(m_TransformPaths, s => fullPath == s) == -1)
                {
                    // mask does not map to an existing hierarchy node. It's invalid.
                    m_NodeInfos[i].m_State = NodeInfo.State.invalid;
                }
                else
                {
                    m_NodeInfos[i].m_State = NodeInfo.State.enabled;
                }


                m_NodeInfos[i].m_Expanded     = true;
                m_NodeInfos[i].m_ParentIndex  = -1;
                m_NodeInfos[i].m_ChildIndices = new List <int>();

                m_NodeInfos[i].m_Depth = i == 0 ? 0 : fullPath.Count(f => f == '/');

                string parentPath = "";
                int    lastIndex  = fullPath.LastIndexOf('/');
                if (lastIndex > 0)
                {
                    parentPath = fullPath.Substring(0, lastIndex);
                }

                lastIndex             = lastIndex == -1 ? 0 : lastIndex + 1;
                m_NodeInfos[i].m_Name = fullPath.Substring(lastIndex);

                for (int j = 1; j < i; j++) // parents are already processed
                {
                    string otherPath = paths[j];
                    if (parentPath != "" && otherPath == parentPath)
                    {
                        m_NodeInfos[i].m_ParentIndex = j;
                        m_NodeInfos[j].m_ChildIndices.Add(i);
                    }
                }

                prop.Next(false);
            }
        }