Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        void AnimationSplitTable()
        {
            if (m_ClipList == null)
            {
                m_ClipList = new ReorderableList(new List <AnimationClipInfoProperties>(), typeof(string), false, true, true, true);
                m_ClipList.onAddCallback       = AddClipInList;
                m_ClipList.onSelectCallback    = SelectClipInList;
                m_ClipList.onRemoveCallback    = RemoveClipInList;
                m_ClipList.drawElementCallback = DrawClipElement;
                m_ClipList.drawHeaderCallback  = DrawClipHeader;
                m_ClipList.elementHeight       = 16;
                UpdateList();
                m_ClipList.index = selectedClipIndex;
            }
            m_ClipList.DoLayoutList();

            EditorGUI.BeginChangeCheck();

            // Show selected clip info
            {
                AnimationClipInfoProperties clip = GetSelectedClipInfo();
                if (clip == null)
                {
                    return;
                }

                if (m_AnimationClipEditor != null && selectedClipIndex != -1)
                {
                    GUILayout.Space(5);

                    AnimationClip actualClip = m_AnimationClipEditor.target as AnimationClip;

                    if (!actualClip.legacy)
                    {
                        GetSelectedClipInfo().AssignToPreviewClip(actualClip);
                    }

                    TakeInfo[] importedTakeInfos = singleImporter.importedTakeInfos;
                    string[]   takeNames         = new string[importedTakeInfos.Length];
                    for (int i = 0; i < importedTakeInfos.Length; i++)
                    {
                        takeNames[i] = importedTakeInfos[i].name;
                    }

                    EditorGUI.BeginChangeCheck();
                    string currentName = clip.name;
                    int    takeIndex   = ArrayUtility.IndexOf(takeNames, clip.takeName);
                    m_AnimationClipEditor.takeNames = takeNames;
                    m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName);
                    m_AnimationClipEditor.DrawHeader();

                    if (EditorGUI.EndChangeCheck())
                    {
                        clip.name = clip.name.Trim();
                        if (clip.name == String.Empty)
                        {
                            clip.name = currentName;
                        }
                        // We renamed the clip name, try to maintain the localIdentifierInFile so we don't lose any data.
                        if (clip.name != currentName)
                        {
                            var newName = clip.name;
                            clip.name = currentName;
                            clip.name = MakeUniqueClipName(newName);

                            TransferDefaultClipsToCustomClips();
                            UnityType animationClipType = UnityType.FindTypeByName("AnimationClip");
                            ImportSettingInternalID.Rename(serializedObject, animationClipType, currentName, clip.name);
                        }

                        int newTakeIndex = m_AnimationClipEditor.takeIndex;
                        if (newTakeIndex != -1 && newTakeIndex != takeIndex)
                        {
                            clip.name = MakeUniqueClipName(takeNames[newTakeIndex]);
                            SetupTakeNameAndFrames(clip, importedTakeInfos[newTakeIndex]);
                            GUIUtility.keyboardControl = 0;
                            SelectClip(selectedClipIndex);

                            // actualClip has been changed by SelectClip
                            actualClip = m_AnimationClipEditor.target as AnimationClip;
                        }
                    }

                    m_AnimationClipEditor.OnInspectorGUI();

                    AvatarMaskSettings(GetSelectedClipInfo());

                    if (!actualClip.legacy)
                    {
                        GetSelectedClipInfo().ExtractFromPreviewClip(actualClip);
                    }
                }
            }

            if (EditorGUI.EndChangeCheck() || m_AnimationClipEditor.needsToGenerateClipInfo)
            {
                TransferDefaultClipsToCustomClips();
                m_AnimationClipEditor.needsToGenerateClipInfo = false;
            }
        }
        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);
        }
        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);
        }
        private void AnimationSplitTable()
        {
            if (this.m_ClipList == null)
            {
                this.m_ClipList = new ReorderableList(new List <AnimationClipInfoProperties>(), typeof(string), false, true, true, true);
                this.m_ClipList.onAddCallback       = new ReorderableList.AddCallbackDelegate(this.AddClipInList);
                this.m_ClipList.onSelectCallback    = new ReorderableList.SelectCallbackDelegate(this.SelectClipInList);
                this.m_ClipList.onRemoveCallback    = new ReorderableList.RemoveCallbackDelegate(this.RemoveClipInList);
                this.m_ClipList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawClipElement);
                this.m_ClipList.drawHeaderCallback  = new ReorderableList.HeaderCallbackDelegate(this.DrawClipHeader);
                this.m_ClipList.elementHeight       = 16f;
                this.UpdateList();
                this.m_ClipList.index = this.selectedClipIndex;
            }
            this.m_ClipList.DoLayoutList();
            EditorGUI.BeginChangeCheck();
            AnimationClipInfoProperties selectedClipInfo = this.GetSelectedClipInfo();

            if (selectedClipInfo != null)
            {
                if (this.m_AnimationClipEditor != null && this.selectedClipIndex != -1)
                {
                    GUILayout.Space(5f);
                    AnimationClip animationClip = this.m_AnimationClipEditor.target as AnimationClip;
                    if (!animationClip.legacy)
                    {
                        this.GetSelectedClipInfo().AssignToPreviewClip(animationClip);
                    }
                    TakeInfo[] importedTakeInfos = this.singleImporter.importedTakeInfos;
                    string[]   array             = new string[importedTakeInfos.Length];
                    for (int i = 0; i < importedTakeInfos.Length; i++)
                    {
                        array[i] = importedTakeInfos[i].name;
                    }
                    EditorGUI.BeginChangeCheck();
                    string name = selectedClipInfo.name;
                    int    num  = ArrayUtility.IndexOf <string>(array, selectedClipInfo.takeName);
                    this.m_AnimationClipEditor.takeNames = array;
                    this.m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf <string>(array, selectedClipInfo.takeName);
                    this.m_AnimationClipEditor.DrawHeader();
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (selectedClipInfo.name != name)
                        {
                            this.TransferDefaultClipsToCustomClips();
                            PatchImportSettingRecycleID.Patch(base.serializedObject, 74, name, selectedClipInfo.name);
                        }
                        int takeIndex = this.m_AnimationClipEditor.takeIndex;
                        if (takeIndex != -1 && takeIndex != num)
                        {
                            selectedClipInfo.name = this.MakeUniqueClipName(array[takeIndex]);
                            this.SetupTakeNameAndFrames(selectedClipInfo, importedTakeInfos[takeIndex]);
                            GUIUtility.keyboardControl = 0;
                            this.SelectClip(this.selectedClipIndex);
                            animationClip = (this.m_AnimationClipEditor.target as AnimationClip);
                        }
                    }
                    this.m_AnimationClipEditor.OnInspectorGUI();
                    this.AvatarMaskSettings(this.GetSelectedClipInfo());
                    if (!animationClip.legacy)
                    {
                        this.GetSelectedClipInfo().ExtractFromPreviewClip(animationClip);
                    }
                }
                if (EditorGUI.EndChangeCheck() || this.m_AnimationClipEditor.needsToGenerateClipInfo)
                {
                    this.TransferDefaultClipsToCustomClips();
                    this.m_AnimationClipEditor.needsToGenerateClipInfo = false;
                }
            }
        }
Ejemplo 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);
             }
         }
     }
 }
Ejemplo n.º 7
0
        private void ReadPreferences()
        {
            m_ScriptEditorPath.str = ScriptEditorUtility.GetExternalScriptEditor();
            m_ScriptEditorArgs     = ScriptEditorUtility.GetExternalScriptEditorArgs();

            m_ExternalEditorSupportsUnityProj = EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false);
            m_ImageAppPath.str = EditorPrefs.GetString("kImagesDefaultApp");

            m_ScriptApps         = BuildAppPathList(m_ScriptEditorPath, kRecentScriptAppsKey, "internal");
            m_ScriptAppsEditions = new string[m_ScriptApps.Length];

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                foreach (var vsPaths in SyncVS.InstalledVisualStudios.Values)
                {
                    foreach (var vsPath in vsPaths)
                    {
                        int index = Array.IndexOf(m_ScriptApps, vsPath.Path);
                        if (index == -1)
                        {
                            ArrayUtility.Add(ref m_ScriptApps, vsPath.Path);
                            ArrayUtility.Add(ref m_ScriptAppsEditions, vsPath.Edition);
                        }
                        else
                        {
                            m_ScriptAppsEditions[index] = vsPath.Edition;
                        }
                    }
                }
            }

            var foundScriptEditorPaths = ScriptEditorUtility.GetFoundScriptEditorPaths(Application.platform);

            foreach (var scriptEditorPath in foundScriptEditorPaths.Keys)
            {
                ArrayUtility.Add(ref m_ScriptApps, scriptEditorPath);
                ArrayUtility.Add(ref m_ScriptAppsEditions, null);
            }

            m_ImageApps = BuildAppPathList(m_ImageAppPath, kRecentImageAppsKey, "");

            m_ScriptAppDisplayNames = BuildFriendlyAppNameList(m_ScriptApps, m_ScriptAppsEditions, foundScriptEditorPaths,
                                                               "Open by file extension");

            m_ImageAppDisplayNames = BuildFriendlyAppNameList(m_ImageApps, null, null,
                                                              L10n.Tr("Open by file extension"));

            m_DiffTools = InternalEditorUtility.GetAvailableDiffTools();

            // only show warning if has team license
            if ((m_DiffTools == null || m_DiffTools.Length == 0) && InternalEditorUtility.HasTeamLicense())
            {
                m_noDiffToolsMessage = InternalEditorUtility.GetNoDiffToolsDetectedMessage();
            }

            string diffTool = EditorPrefs.GetString("kDiffsDefaultApp");

            m_DiffToolIndex = ArrayUtility.IndexOf(m_DiffTools, diffTool);
            if (m_DiffToolIndex == -1)
            {
                m_DiffToolIndex = 0;
            }

            m_AutoRefresh = EditorPrefs.GetBool("kAutoRefresh");

            m_ReopenLastUsedProjectOnStartup = EditorPrefs.GetBool("ReopenLastUsedProjectOnStartup");

            m_UseOSColorPicker            = EditorPrefs.GetBool("UseOSColorPicker");
            m_EnableEditorAnalytics       = EditorPrefs.GetBool("EnableEditorAnalytics", true);
            m_ShowAssetStoreSearchHits    = EditorPrefs.GetBool("ShowAssetStoreSearchHits", true);
            m_VerifySavingAssets          = EditorPrefs.GetBool("VerifySavingAssets", false);
            m_ScriptCompilationDuringPlay = (ScriptChangesDuringPlayOptions)EditorPrefs.GetInt("ScriptCompilationDuringPlay", 0);
            m_DeveloperMode = Unsupported.IsDeveloperMode();

            m_GICacheSettings.m_EnableCustomPath = EditorPrefs.GetBool("GICacheEnableCustomPath");
            m_GICacheSettings.m_CachePath        = EditorPrefs.GetString("GICacheFolder");
            m_GICacheSettings.m_MaximumSize      = EditorPrefs.GetInt("GICacheMaximumSizeGB", 10);
            m_GICacheSettings.m_CompressionLevel = EditorPrefs.GetInt("GICacheCompressionLevel");

            m_SpriteAtlasCacheSize = EditorPrefs.GetInt("SpritePackerCacheMaximumSizeGB");

            m_AllowAttachedDebuggingOfEditor = EditorPrefs.GetBool("AllowAttachedDebuggingOfEditor", true);
            m_EnableEditorLocalization       = EditorPrefs.GetBool("Editor.kEnableEditorLocalization", true);
            m_SelectedLanguage           = EditorPrefs.GetString("Editor.kEditorLocale", LocalizationDatabase.GetDefaultEditorLanguage().ToString());
            m_AllowAlphaNumericHierarchy = EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false);

            m_CompressAssetsOnImport = Unsupported.GetApplicationSettingCompressAssetsOnImport();
            m_GpuDevice = EditorPrefs.GetString("GpuDeviceName");

            foreach (IPreferenceWindowExtension extension in prefWinExtensions)
            {
                extension.ReadPreferences();
            }
        }
Ejemplo n.º 8
0
        internal override void OnEnable()
        {
            m_AnimationType = serializedObject.FindProperty("m_AnimationType");
            m_AvatarSource  = serializedObject.FindProperty("m_LastHumanDescriptionAvatarSource");

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

            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_SkinWeightsMode   = serializedObject.FindProperty("skinWeightsMode");
            m_MaxBonesPerVertex = serializedObject.FindProperty("maxBonesPerVertex");
            m_MinBoneWeight     = serializedObject.FindProperty("minBoneWeight");

            m_OptimizeGameObjects = serializedObject.FindProperty("m_OptimizeGameObjects");

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

            m_HumanBoneArray = serializedObject.FindProperty("m_HumanDescription.m_Human");
            m_Skeleton       = serializedObject.FindProperty("m_HumanDescription.m_Skeleton");

            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>();

            UpdateBipedMappingReport();

            if (m_AnimationType.intValue == (int)ModelImporterAnimationType.Human && m_Avatar == null)
            {
                ResetAvatar();
            }
        }
        private void DrawToolbar()
        {
            if (m_IsMultiEditing)
            {
                EditorGUILayout.HelpBox(s_Styles.disabledEditMessage, MessageType.Info);
            }

            EditorGUI.BeginDisabled(m_IsMultiEditing);
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditMode.DoInspectorToolbar(s_Styles.sceneViewEditModes, s_Styles.toolContents, GetBounds, this);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Tools box
            GUILayout.BeginVertical(EditorStyles.helpBox);
            string helpText = Styles.baseSceneEditingToolText;

            if (sceneViewEditing)
            {
                int index = ArrayUtility.IndexOf(s_Styles.sceneViewEditModes, EditMode.editMode);
                if (index >= 0)
                {
                    helpText = s_Styles.toolNames[index].text;
                }
            }

            GUILayout.Label(helpText, s_Styles.richTextMiniLabel);
            GUILayout.EndVertical();

            // Editing mode toolbar
            if (sceneViewEditing)
            {
                switch (EditMode.editMode)
                {
                case EditMode.SceneViewEditMode.LineRendererEdit:
                    DrawEditPointTools();
                    break;

                case EditMode.SceneViewEditMode.LineRendererCreate:
                    CreatePointTools();
                    break;
                }
            }
            if (!sceneViewEditing)
            {
                EditorGUI.BeginChangeCheck();
                showSimplifyPreview = EditorGUILayout.Toggle(s_Styles.simplifyPreview, showSimplifyPreview);
                EditorGUILayout.BeginHorizontal();
                simplifyTolerance = Mathf.Max(0, EditorGUILayout.FloatField(s_Styles.tolerance, simplifyTolerance));
                if (GUILayout.Button(s_Styles.simplify, EditorStyles.miniButton))
                {
                    SimplifyPoints();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    ResetSimplifyPreview();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
            EditorGUILayout.Space();
            EditorGUI.EndDisabled();
        }
Ejemplo n.º 10
0
        internal static void DoBoneHandle(Transform target, Dictionary <Transform, bool> validBones, BoneRenderer renderer)
        {
            int   id  = target.name.GetHashCode();
            Event evt = Event.current;

            bool hasValidChildBones = false;

            if (validBones != null)
            {
                foreach (Transform child in target)
                {
                    if (validBones.ContainsKey(child))
                    {
                        hasValidChildBones = true;
                        break;
                    }
                }
            }

            Vector3 basePoint = target.position;

            List <Vector3> endPoints = new List <Vector3>();

            // [case 525602] do not draw root.
            if (!hasValidChildBones && target.parent != null)
            {
                endPoints.Add(target.position + (target.position - target.parent.position) * 0.4f);
            }
            else
            {
                foreach (Transform child in target)
                {
                    // Only render bone connections to valid bones
                    // (except if no child bones are valid - then draw all connections)
                    if (validBones != null && !validBones.ContainsKey(child))
                    {
                        continue;
                    }

                    endPoints.Add(child.position);
                }
            }

            for (int i = 0; i < endPoints.Count; i++)
            {
                Vector3 endPoint = endPoints[i];


                switch (evt.GetTypeForControl(id))
                {
                case EventType.Layout:
                {
                    // TODO : This is slow and should be revisited prior to exposing bone handles
                    Vector3[] vertices = BoneRenderer.GetBoneWireVertices(basePoint, endPoint);
                    if (vertices != null)
                    {
                        HandleUtility.AddControl(id, DistanceToPolygone(vertices));
                    }

                    break;
                }

                case EventType.MouseMove:
                    if (id == HandleUtility.nearestControl)
                    {
                        HandleUtility.Repaint();
                    }
                    break;

                case EventType.MouseDown:
                {
                    // am I closest to the thingy?
                    if (!evt.alt && HandleUtility.nearestControl == id && evt.button == 0)
                    {
                        GUIUtility.hotControl = id;     // Grab mouse focus
                        if (evt.shift)
                        {
                            Object[] selected = Selection.objects;
                            if (ArrayUtility.Contains(selected, target) == false)
                            {
                                ArrayUtility.Add(ref selected, target);
                                Selection.objects = selected;
                            }
                        }
                        else
                        {
                            Selection.activeObject = target;
                        }

                        EditorGUIUtility.PingObject(target);

                        evt.Use();
                    }
                    break;
                }

                case EventType.MouseDrag:
                {
                    if (!evt.alt && GUIUtility.hotControl == id)
                    {
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new UnityEngine.Object[] { target };
                        DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(target));

                        // having a hot control set during drag makes the control eat the drag events
                        // and dragging of bones no longer works over the avatar configure window
                        // see case 912016
                        GUIUtility.hotControl = 0;

                        evt.Use();
                    }
                    break;
                }

                case EventType.MouseUp:
                {
                    if (GUIUtility.hotControl == id && (evt.button == 0 || evt.button == 2))
                    {
                        GUIUtility.hotControl = 0;
                        evt.Use();
                    }
                    break;
                }

                case EventType.Repaint:
                {
                    color = GUIUtility.hotControl == 0 && HandleUtility.nearestControl == id ? Handles.preselectionColor : color;
                    if (hasValidChildBones)
                    {
                        renderer.AddBoneInstance(basePoint, endPoint, color);
                    }
                    else
                    {
                        renderer.AddBoneLeafInstance(basePoint, target.rotation, (endPoint - basePoint).magnitude, color);
                    }
                }
                break;
                }
            }
        }
Ejemplo n.º 11
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);
            }
        }