void ShowUpdateReferenceClip() { if (targets.Length > 1 || m_AvatarSetup.intValue == (int)ModelImporterAvatarSetup.CopyFromOther || !m_Avatar || !m_Avatar.isValid) { return; } string[] paths = new string[0]; ModelImporter importer = target as ModelImporter; if (importer.referencedClips.Length > 0) { foreach (string clipGUID in importer.referencedClips) { ArrayUtility.Add(ref paths, AssetDatabase.GUIDToAssetPath(clipGUID)); } } // Show only button if some clip reference this avatar. if (paths.Length > 0 && GUILayout.Button(Styles.UpdateReferenceClips, GUILayout.Width(150))) { foreach (string path in paths) { SetupReferencedClip(path); } try { AssetDatabase.StartAssetEditing(); foreach (string path in paths) { AssetDatabase.ImportAsset(path); } } finally { AssetDatabase.StopAssetEditing(); } } }
private void ShowUpdateReferenceClip() { if (((base.targets.Length <= 1) && (this.animationType == ModelImporterAnimationType.Human)) && !this.m_CopyAvatar.boolValue) { string[] array = new string[0]; ModelImporter target = this.target as ModelImporter; if (target.referencedClips.Length > 0) { foreach (string str in target.referencedClips) { ArrayUtility.Add <string>(ref array, AssetDatabase.GUIDToAssetPath(str)); } } if (array.Length > 0) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(150f) }; if (GUILayout.Button(styles.UpdateReferenceClips, options)) { foreach (string str2 in array) { this.SetupReferencedClip(str2); } try { AssetDatabase.StartAssetEditing(); foreach (string str3 in array) { AssetDatabase.ImportAsset(str3); } } finally { AssetDatabase.StopAssetEditing(); } } } } }
private void FilePopup(GUIContent label, string selectedString, ref string[] names, ref string[] paths, RefString outString, string defaultString, Action onChanged) { GUIStyle style = EditorStyles.popup; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(label, style); int[] selected = new int[0]; if (paths.Contains(selectedString)) { selected = new[] { Array.IndexOf(paths, selectedString) } } ; GUIContent text = new GUIContent(selected.Length == 0 ? defaultString : names[selected[0]]); Rect r = GUILayoutUtility.GetRect(GUIContent.none, style); AppsListUserData ud = new AppsListUserData(paths, outString, onChanged); if (EditorGUI.DropdownButton(r, text, FocusType.Passive, style)) { ArrayUtility.Add(ref names, Styles.browse.text); EditorUtility.DisplayCustomMenu(r, names, selected, AppsListClick, ud, false); } GUILayout.EndHorizontal(); }
internal static void DoBoneHandle(Transform target, Dictionary <Transform, bool> validBones) { 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: { float len = Vector3.Magnitude(endPoint - basePoint); float size = len * k_BoneThickness; Vector3[] vertices = GetBoneVertices(endPoint, basePoint, size); 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: { float len = Vector3.Magnitude(endPoint - basePoint); if (len > 0) { color = GUIUtility.hotControl == 0 && HandleUtility.nearestControl == id ? Handles.preselectionColor : color; // size used to be based on sqrt of length but that makes bones for // huge creatures hair-thin and bones for tiny creatures bulky. // So base on a fixed proportion instead. float size = len * k_BoneThickness; if (hasValidChildBones) { Handles.DrawBone(endPoint, basePoint, size); } else { Handles.SphereHandleCap(id, basePoint, target.rotation, size * .2f, EventType.Repaint); } } break; } } } }
private void ReadPreferences() { m_ScriptEditorPath.str = CodeEditor.Editor.EditorInstallation.Path; 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]; var foundScriptEditorPaths = CodeEditor.Editor.GetFoundScriptEditorPaths(); 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_EnableCodeCoverage = EditorPrefs.GetBool("CodeCoverageEnabled", false); m_CompressAssetsOnImport = Unsupported.GetApplicationSettingCompressAssetsOnImport(); m_GpuDevice = EditorPrefs.GetString("GpuDeviceName"); foreach (IPreferenceWindowExtension extension in prefWinExtensions) { extension.ReadPreferences(); } }
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; } } }