private void CopyStagingAreaIntoDestination(BuildPostProcessArgs args, HashSet <string> filesToNotOverwrite) { if (GetInstallingIntoBuildsFolder(args)) { string dst = Unsupported.GetBaseUnityDeveloperFolder() + "/" + GetDestinationFolderForInstallingIntoBuildsFolder(args); if (!Directory.Exists(Path.GetDirectoryName(dst))) { throw new Exception("Installing in builds folder failed because the player has not been built (You most likely want to enable 'Development build')."); } FileUtil.CopyDirectoryFiltered(args.stagingAreaData, dst, true, f => true, recursive: true); } else { DeleteDestination(args); // Copy entire stagingarea over CopyFilesToDestination(args.stagingArea, GetDestinationFolder(args), filesToNotOverwrite); args.report.RecordFilesMoved(args.stagingArea, GetDestinationFolder(args)); } }
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) { if (evt.target is Node) { var canViewShader = node.hasPreview || node is IMasterNode; evt.menu.AppendAction("Copy Shader", CopyToClipboard, _ => canViewShader ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Hidden, GenerationMode.ForReals); evt.menu.AppendAction("Show Generated Code", ShowGeneratedCode, _ => canViewShader ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Hidden, GenerationMode.ForReals); if (Unsupported.IsDeveloperMode()) { evt.menu.AppendAction("Show Preview Code", ShowGeneratedCode, _ => canViewShader ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Hidden, GenerationMode.Preview); } } base.BuildContextualMenu(evt); }
void OnContextChange() { // Sync the toolbar m_PickToggle.SetValueWithoutNotify(m_Context.pickElement); m_ShowLayoutToggle.SetValueWithoutNotify(m_Context.showLayoutBound); if (Unsupported.IsDeveloperBuild()) { m_RepaintOverlayToggle.SetValueWithoutNotify(m_Context.showRepaintOverlay); m_UXMLLiveReloadToggle.SetValueWithoutNotify(m_Context.uxmlLiveReload); m_ShowDrawStatsToggle.SetValueWithoutNotify(m_Context.showDrawStats); var updater = (panel as BaseVisualElementPanel)?.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater; if (updater != null) { updater.DebugGetRenderChain().drawStats = m_Context.showDrawStats; } } panelDebug?.MarkDirtyRepaint(); panelDebug?.MarkDebugContainerDirtyRepaint(); }
/// <summary> /// Called by PrintSelectedModelsToPreview . Actually draws the model on the window. /// </summary> /// <param name="bareMesh"></param> /// <param name="r"></param> /// <param name="gstyle"></param> public void DrawRenderPreview(BareDaggerfallMeshStats bareMesh, Rect r, GUIStyle gstyle) { if (previewRenderUtility == null) { previewRenderUtility = new PreviewRenderUtility(); } if (bareMesh == null) { Debug.Log("No Mesh Found."); return; } if (previewRenderUtility.camera == null) { return; } previewRenderUtility.BeginPreview(r, gstyle); InputPreviewWindowControls(r); if (bareMesh.mesh != null) { for (int i = 0; i < bareMesh.SubMeshIndex; i++) { previewRenderUtility.DrawMesh(bareMesh.mesh, Vector3.zero, Quaternion.Euler(-30f, 0f, 0f) * Quaternion.Euler(0f, 60, 0f), bareMesh.mat[i], i, bareMesh.mProp); } } bool fog = false; Unsupported.SetRenderSettingsUseFogNoDirty(false); previewRenderUtility.camera.Render(); Unsupported.SetRenderSettingsUseFogNoDirty(fog); Texture texture = previewRenderUtility.EndPreview(); GUI.DrawTexture(r, texture); }
internal static GameObject FindFirstGameObjectThatMatchesFileID(Transform searchRoot, UInt64 fileID, bool generate) { GameObject result = null; var transformVisitor = new TransformVisitor(); transformVisitor.VisitAndAllowEarlyOut(searchRoot, (transform, userdata) => { UInt64 id = generate ? Unsupported.GetOrGenerateFileIDHint(transform.gameObject) : GetPrefabOrVariantFileID(transform.gameObject); if (id == fileID) { result = transform.gameObject; return(false); // stop searching } return(true); // continue searching } , null); return(result); }
static List <MenuItemData> GetSortedMenuItems() { var menus = Unsupported.GetSubmenus("Component"); var commands = Unsupported.GetSubmenusCommands("Component"); var menuItems = new List <MenuItemData>(menus.Length); var legacyMenuItems = new List <MenuItemData>(menus.Length); const string kLegacyString = "legacy"; for (var i = 0; i < menus.Length; i++) { var menuPath = menus[i]; bool isLegacy = menuPath.ToLower().Contains(kLegacyString); var item = new MenuItemData { path = menuPath, command = commands[i], isLegacy = isLegacy }; if (isLegacy) { legacyMenuItems.Add(item); } else { menuItems.Add(item); } } int comparison(MenuItemData x, MenuItemData y) => string.CompareOrdinal(x.path, y.path); menuItems.Sort(comparison); legacyMenuItems.Sort(comparison); menuItems.AddRange(legacyMenuItems); return(menuItems); }
VslSSTaskHandle(Span <T> samples, int dim) { this.Dim = new int[] { dim }; this.SampleCount = new int[] { samples.Length / dim }; this.MatrixFormat = new VslSSMatrixStorage[] { VslSSMatrixStorage.VSL_SS_MATRIX_STORAGE_ROWS }; this.TaskPtr = IntPtr.Zero; if (typeof(T) == typeof(float)) { VSL.vslsSSNewTask(ref TaskPtr, ref Dim[0], ref SampleCount[0], ref MatrixFormat[0], ref MemoryMarshal.Cast <T, float>(samples)[0]).AutoThrow(); } else if (typeof(T) == typeof(double)) { VSL.vsldSSNewTask(ref TaskPtr, ref Dim[0], ref SampleCount[0], ref MatrixFormat[0], ref MemoryMarshal.Cast <T, double>(samples)[0]).AutoThrow(); } else { throw Unsupported.define <T>(); } }
void BuildGraphViewContextualMenu() { if (!(m_Evt.target is GraphView)) { return; } m_Evt.menu.AppendAction("Create Node", menuAction => { m_GraphView.window.DisplaySmartSearch(menuAction); }); m_Evt.menu.AppendAction("Create Placemat", menuAction => { Vector2 mousePosition = menuAction?.eventInfo?.mousePosition ?? Event.current.mousePosition; Vector2 graphPosition = m_GraphView.contentViewContainer.WorldToLocal(mousePosition); m_Store.Dispatch(new CreatePlacematAction(null, new Rect(graphPosition.x, graphPosition.y, 200, 200))); }); m_Evt.menu.AppendSeparator(); m_Evt.menu.AppendAction("Cut", menuAction => m_GraphView.InvokeCutSelectionCallback(), x => m_GraphView.CanCutSelection() ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); m_Evt.menu.AppendAction("Copy", menuAction => m_GraphView.InvokeCopySelectionCallback(), x => m_GraphView.CanCopySelection() ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); m_Evt.menu.AppendAction("Paste", menuAction => m_GraphView.InvokePasteCallback(), x => m_GraphView.CanPaste() ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); if (Unsupported.IsDeveloperBuild()) { m_Evt.menu.AppendSeparator(); m_Evt.menu.AppendAction("Internal/Refresh All UI", menuAction => m_Store.Dispatch(new RefreshUIAction(UpdateFlags.All))); } }
public override void OnActivate(string searchContext, VisualElement rootElement) { builderTemplate.CloneTree(rootElement); var styleSheet = BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.SettingsUIPath + "/BuilderSettingsView.uss"); rootElement.styleSheets.Add(styleSheet); var editorExtensionsModeToggle = rootElement.Q <Toggle>(k_EditorExtensionsModeToggleName); editorExtensionsModeToggle.SetValueWithoutNotify(BuilderProjectSettings.enableEditorExtensionModeByDefault); editorExtensionsModeToggle.RegisterValueChangedCallback(e => { BuilderProjectSettings.enableEditorExtensionModeByDefault = e.newValue; }); var zoomToggle = rootElement.Q <Toggle>(k_DisableMouseWheelZoomingToggleName); zoomToggle.SetValueWithoutNotify(BuilderProjectSettings.disableMouseWheelZooming); zoomToggle.RegisterValueChangedCallback(e => { BuilderProjectSettings.disableMouseWheelZooming = e.newValue; }); var absolutePlacementToggle = rootElement.Q <Toggle>(k_EnableAbsolutePositionPlacementToggleName); absolutePlacementToggle.SetValueWithoutNotify(BuilderProjectSettings.enableAbsolutePositionPlacement); absolutePlacementToggle.RegisterValueChangedCallback(e => { BuilderProjectSettings.enableAbsolutePositionPlacement = e.newValue; }); if (!Unsupported.IsDeveloperMode()) { absolutePlacementToggle.style.display = DisplayStyle.None; } base.OnActivate(searchContext, rootElement); }
/// <summary> /// Overrides the built in selection duplication to maintain sibling order of the selection. But only if at least one of the selection is under a CSG Model. /// </summary> /// <returns><c>true</c>, if our custom duplication took place (and one of the selection was under a CSG Model), <c>false</c> otherwise in which case the duplication event should not be consumed so that Unity will duplicate for us.</returns> public static bool DuplicateSelection() { List <Transform> selectedTransforms = Selection.transforms.ToList(); // Whether any of the selection objects are under a CSG Model bool shouldCustomDuplicationOccur = false; for (int i = 0; i < selectedTransforms.Count; i++) { if (selectedTransforms[i].GetComponentInParent <CSGModel>() != null) { shouldCustomDuplicationOccur = true; } } if (shouldCustomDuplicationOccur) // Some of the objects are under a CSG Model, so peform our special duplication override { // Sort the selected transforms in order of sibling index selectedTransforms.Sort((x, y) => x.GetSiblingIndex().CompareTo(y.GetSiblingIndex())); GameObject[] newObjects = new GameObject[Selection.gameObjects.Length]; // Walk through each selected object in the correct order, duplicating them one by one for (int i = 0; i < selectedTransforms.Count; i++) { // Temporarily set the selection to the single entry Selection.activeGameObject = selectedTransforms[i].gameObject; // Duplicate the single entry Unsupported.DuplicateGameObjectsUsingPasteboard(); // Cache the new entry, so when we're done we reselect all new objects newObjects[i] = Selection.activeGameObject; } // Finished duplicating, select all new objects Selection.objects = newObjects; } // Whether custom duplication took place and whether the Duplicate event should be consumed return(shouldCustomDuplicationOccur); }
public virtual void OnDisable() { ////FIXME: The code below wreaks havoc with tabbed editors. Triggering a re-import will //// cause all active editors to be destroyed which, if we're part of a tabbed editor, //// will take down our parent while it is trying to switch editors. Also, we'll be //// doing all this while InspectorWindow.OnGUI() is still going through the active //// editors to draw them so we're killing them right under its nose. // When destroying the inspector check if we have any unapplied modifications // and apply them. AssetImporter importer = target as AssetImporter; if (Unsupported.IsDestroyScriptableObject(this) && m_MightHaveModified && importer != null && HasModified() && !AssetWasUpdated()) { string dialogText = string.Format(L10n.Tr("Unapplied import settings for \'{0}\'"), importer.assetPath); if (targets.Length > 1) { dialogText = string.Format(L10n.Tr("Unapplied import settings for \'{0}\' files"), targets.Length); } if (EditorUtility.DisplayDialog(L10n.Tr("Unapplied import settings"), dialogText, L10n.Tr("Apply"), L10n.Tr("Revert"))) { Apply(); m_MightHaveModified = false; ImportAssets(GetAssetPaths()); } } // Only cache SerializedObject if it has modified properties. // If we have multiple editors (e.g. a tabbed editor and its editor for the active tab) we don't // want the one that doesn't do anything with the SerializedObject to overwrite the cache. if (m_SerializedObject != null && m_SerializedObject.hasModifiedProperties) { m_SerializedObject.Cache(GetInstanceID()); m_SerializedObject = null; } }
private static ProcessStartInfo GetJamStartInfo(bool includeModules) { StringBuilder moduleArgs = new StringBuilder(); moduleArgs.Append("jam.pl LiveReloadableEditorAssemblies " + InternalEditorUtility.GetBuildSystemVariationArgs()); if (includeModules) { foreach (string target in ModuleManager.GetJamTargets()) { moduleArgs.Append(" ").Append(target); } } var psi = new ProcessStartInfo { WorkingDirectory = Unsupported.GetBaseUnityDeveloperFolder(), RedirectStandardOutput = true, RedirectStandardError = false, //The only reason jam.pl exists is that I cannot figure out how to call jam.bat, or jam.exe directly. magic. Arguments = moduleArgs.ToString(), FileName = "perl", }; var path = Environment.GetEnvironmentVariable("PATH") ?? ""; // on macOS the typical mercurial path might not be in our environment variable, so add it for executing jam if (Application.platform == RuntimePlatform.OSXEditor) { var localBin = "/usr/local/bin"; if (!path.Contains(localBin)) { path = $"{path}:{localBin}"; } } psi.EnvironmentVariables["PATH"] = path; return(psi); }
public static void Delete(GameObject gameObject) { var rigBuilder = gameObject.GetComponent <RigBuilder>(); var vaRigBuilder = gameObject.GetComponent <VeryAnimationRigBuilder>(); var vaRig = GetVeryAnimationRig(gameObject); var rig = vaRig != null?vaRig.GetComponent <Rig>() : null; var index = rigBuilder != null && rig != null?rigBuilder.layers.FindIndex(x => x.rig == rig) : -1; if (rig != null) { Selection.activeGameObject = rig.gameObject; Unsupported.DeleteGameObjectSelection(); if (rig != null) { return; } rig = null; } if (vaRigBuilder != null) { Undo.DestroyObjectImmediate(vaRigBuilder); vaRigBuilder = null; } if (rigBuilder != null) { if (index >= 0 && index < rigBuilder.layers.Count) { Undo.RecordObject(rigBuilder, ""); rigBuilder.layers.RemoveAt(index); if (rigBuilder.layers.Count == 0) { Undo.DestroyObjectImmediate(rigBuilder); } } rigBuilder = null; } }
private static void Duplicate() { //GameObject[] gameObjects = Selection.gameObjects; //Object[] newObjects = new Object[gameObjects.Length]; GameObject[] gameObjects = Selection.gameObjects; if (gameObjects.Length == 0) { return; } bool isTop = false; int nSiblingIndex = 0; if (gameObjects.Length == 1) { isTop = true; nSiblingIndex = Selection.activeTransform.GetSiblingIndex(); } Unsupported.DuplicateGameObjectsUsingPasteboard(); gameObjects = Selection.gameObjects; for (int i = 0; i < gameObjects.Length; i++) { GameObject gameObject = gameObjects[i]; string strName = gameObject.name; if (strName.EndsWith(")")) { gameObject.name = strName.Remove(strName.Length - 4); } Undo.RegisterCreatedObjectUndo(gameObject, "Duplicate"); } if (isTop) { Selection.activeTransform.SetSiblingIndex(nSiblingIndex + 1); } }
private DocumentationPackageManagerUI(VisualTreeAsset asset) { #if UNITY_2019_1_OR_NEWER root = asset.CloneTree(); var resourcesRoot = "packages/com.unity.package-manager-doctools/Editor/Resources/"; string path = EditorGUIUtility.isProSkin ? resourcesRoot + "Styles/Dark.uss" : resourcesRoot + "Styles/Light.uss"; var styleSheet = EditorGUIUtility.Load(path) as StyleSheet; root.styleSheets.Add(styleSheet); #else root = asset.CloneTree(null); root.AddStyleSheetPath(EditorGUIUtility.isProSkin ? "Styles/Dark" : "Styles/Light"); #endif Add(root); if (!Unsupported.IsDeveloperMode()) { Verbose.visible = false; } GenerateButton.clickable.clicked += GenerateDocClick; Verbose.RegisterValueChangedCallback(evt => VerbosityToggle()); VerbosityToggle(); }
public static int GetServiceEnv(string serviceName) { int result; if (Unsupported.IsDeveloperBuild() || UnityConnect.preferencesEnabled) { result = EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelServer", serviceName)); } else { for (int i = 0; i < UnityConnectPrefs.kEnvironmentFamilies.Length; i++) { string text = UnityConnectPrefs.kEnvironmentFamilies[i]; if (text.Equals(UnityConnect.instance.configuration, StringComparison.InvariantCultureIgnoreCase)) { result = i; return(result); } } result = 0; } return(result); }
static MonoScript FindEvolvePrefabScriptAsset(out string fileID, out string guid, out string path) { var paths = AssetDatabase.GetAllAssetPaths().Where(assetPath => assetPath.EndsWith(".dll") || assetPath.EndsWith(".cs")).ToArray(); fileID = guid = path = ""; foreach (var assetPath in paths) { var result = AssetDatabase.LoadAllAssetsAtPath(assetPath).OfType <MonoScript>().FirstOrDefault(script => script.GetClass() == typeof(EvolvePrefab)); if (result == null) { continue; } path = assetPath; guid = AssetDatabase.AssetPathToGUID(assetPath); fileID = Unsupported.GetLocalIdentifierInFile(result.GetInstanceID()).ToString(); return(result); } return(null); }
void BuildRefactorContextualMenu(IReadOnlyCollection <IGraphElementModel> selectedModels) { var models = selectedModels.OfType <INodeModel>().ToArray(); if (!models.Any()) { return; } var canDisable = models.Any(); var willDisable = models.Any(n => n.State == ModelState.Enabled); if (canDisable) { m_Evt.menu.AppendAction(willDisable ? "Disable Selection" : "Enable Selection", menuAction => { m_Store.Dispatch(new SetNodeEnabledStateAction(models, willDisable ? ModelState.Disabled : ModelState.Enabled)); }); } if (Unsupported.IsDeveloperBuild()) { m_Evt.menu.AppendAction("Internal/Redefine Node", action => { foreach (var model in selectedModels.OfType <NodeModel>()) { model.DefineNode(); } }, _ => DropdownMenuAction.Status.Normal); m_Evt.menu.AppendAction("Internal/Refresh Selected Element(s)", menuAction => { m_Store.Dispatch(new RefreshUIAction(selectedModels.ToList())); }, _ => DropdownMenuAction.Status.Normal); } }
public Object GetActualExportObject(Object obj) { if (!obj) { return(null); } var path = AssetDatabase.GetAssetPath(obj); if (path.StartsWith("Packages/", StringComparison.Ordinal)) { path = path.Substring("Packages/".Length); var indexOfSlash = path.IndexOf("/", StringComparison.Ordinal); var packageName = path.Substring(0, indexOfSlash); path = "Packages/" + packageName; if (!Unsupported.IsDeveloperMode()) { // sanitize: do not allow uploading packages that are in the Library var libraryRoot = Path.GetFullPath(Application.dataPath + "/../Library"); if (Path.GetFullPath(path).StartsWith(libraryRoot, StringComparison.Ordinal)) { return(null); } // sanitize: do not allow re-uploading of Unity-scoped packages if (packageName.StartsWith("com.unity.", StringComparison.OrdinalIgnoreCase)) { return(null); } } return(AssetDatabase.LoadAssetAtPath <DefaultAsset>(path)); } return(obj); }
public virtual void OnDisable() { AssetImporter assetImporter = base.target as AssetImporter; if (Unsupported.IsDestroyScriptableObject(this) && this.m_MightHaveModified && assetImporter != null && !InternalEditorUtility.ignoreInspectorChanges && this.HasModified() && !this.AssetWasUpdated()) { string message = string.Format(L10n.Tr("Unapplied import settings for '{0}'"), assetImporter.assetPath); if (base.targets.Length > 1) { message = string.Format(L10n.Tr("Unapplied import settings for '{0}' files"), base.targets.Length); } if (EditorUtility.DisplayDialog(L10n.Tr("Unapplied import settings"), message, L10n.Tr("Apply"), L10n.Tr("Revert"))) { this.Apply(); this.m_MightHaveModified = false; this.ImportAssets(this.GetAssetPaths()); } } if (this.m_SerializedObject != null && this.m_SerializedObject.hasModifiedProperties) { this.m_SerializedObject.Cache(base.GetInstanceID()); this.m_SerializedObject = null; } }
static BuildAnalyticsTypes.ContextInfo CreateContextInfo(BuildResult result) { var ci = new BuildAnalyticsTypes.ContextInfo(); #if UNITY_INTERNAL ci.internal_build = true; #else ci.internal_build = Unsupported.IsDeveloperMode(); #endif if (result == null) { return(ci); } if (!result.BuildConfiguration.TryGetComponent <DotsRuntimeBuildProfile>(out var profile)) { return(ci); } ci.configuration = profile.Configuration.ToString(); ci.platform = profile.Target.UnityPlatformName; return(ci); }
public bool CopySelectionToPasteboard() { UnityEngine.Object[] array = new UnityEngine.Object[0]; Vector3[] monoPositions = new Vector3[0]; using (List <UnityEditor.Graphs.Node> .Enumerator enumerator = this.selection.GetEnumerator()) { while (enumerator.MoveNext()) { Node node = (Node)enumerator.Current; if (node is StateNode) { ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateNode).state); ArrayUtility.Add <Vector3>(ref monoPositions, new Vector3(node.position.x, node.position.y, 0f)); } else if (node is StateMachineNode && (node as StateMachineNode).stateMachine != AnimatorControllerTool.tool.stateMachineGraph.parentStateMachine) { ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateMachineNode).stateMachine); ArrayUtility.Add <Vector3>(ref monoPositions, new Vector3(node.position.x, node.position.y, 0f)); } } } foreach (int current in this.edgeGUI.edgeSelection) { EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[current]); foreach (TransitionEditionContext current2 in edgeInfo.transitions) { if (current2.transition != null) { ArrayUtility.Add <UnityEngine.Object>(ref array, current2.transition); ArrayUtility.Add <Vector3>(ref monoPositions, Vector3.zero); } } } Unsupported.CopyStateMachineDataToPasteboard(array, monoPositions, this.tool.animatorController, this.tool.selectedLayerIndex); return(array.Length > 0); }
public static void SetSerializedPropertyWithObject(SerializedProperty serializedProperty, Object referencedObject) { SerializedProperty fileId = serializedProperty.FindPropertyRelative("m_FileId"); SerializedProperty guid = serializedProperty.FindPropertyRelative("m_GUID"); if ((fileId != null) && (guid != null)) { if (referencedObject == null) { fileId.intValue = 0; guid.stringValue = ""; } else { int localFileId = Unsupported.GetLocalIdentifierInFile(referencedObject.GetInstanceID()); fileId.intValue = localFileId; if (localFileId > 0) { guid.stringValue = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(referencedObject)); ; } } } }
internal void DoGUI() { if (m_State.Behavior == MemoryViewerBehavior.Hidden) { return; } var splitterRectVertical = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.Height(5)); var splitterRectHorizontal = new Rect(m_State.MemoryWindowWidth, splitterRectVertical.y, 5, m_State.MemoryWindowHeight); DoSplitter(splitterRectVertical, splitterRectHorizontal); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(m_State.MemoryWindowWidth), GUILayout.Height(m_State.MemoryWindowHeight)); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Group:"); EditorGUI.BeginChangeCheck(); m_State.MemoryGroup = (MemoryGroup)EditorGUILayout.EnumPopup(m_State.MemoryGroup); if (EditorGUI.EndChangeCheck()) { UpdateGeneralStats(); } GUILayout.EndHorizontal(); foreach (var m in GetOrderMemoryTypes()) { DoMemoryToggle(m); } DoMemoryToggle(MemoryType.Total); if (m_State.Behavior == MemoryViewerBehavior.Manual) { GUILayout.Space(10); if (GUILayout.Button("Capture", EditorStyles.miniButton)) { QueueMemoryRequest(m_ExpectedDevice, m_ExpectedPackageFromRequest); } } if (Unsupported.IsDeveloperMode()) { DoDebuggingGUI(); } GUILayout.EndVertical(); var rc = GUILayoutUtility.GetLastRect(); GUILayout.BeginVertical(); // Note: GUILayoutUtility.GetRect must be called for Layout event always var size = GUILayoutUtility.GetRect(GUIContent.none, AndroidLogcatStyles.internalLogStyle, GUILayout.Height(m_State.MemoryWindowHeight)); size.height -= 4; if (m_EntryCount > 0) { DoEntriesGUI(size); } DoGuidelinesGUI(size, m_UpperMemoryBoundry); if (m_EntryCount > 0) { DoSelectedStatsGUI(size); } GUI.Box(new Rect(rc.x + 4, size.y, rc.width - 4, size.height + 1), GUIContent.none, EditorStyles.helpBox); GUI.Box(new Rect(size.x, size.y, size.width + 1, size.height + 1), GUIContent.none, EditorStyles.helpBox); if (m_ExpectedPackageFromRequest == null) { EditorGUI.HelpBox(size, "Select a package", MessageType.Info); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
static void DoFixMissingScript() { if ((brokenAsset == null || brokenAsset.Count == 0) && (brokenScene == null || brokenScene.Count == 0)) { Debug.Log("No prefab / scene to fix"); return; } if (brokenAsset != null) { int count = 0; foreach (var prefabPath in brokenAsset) { count++; EditorUtility.DisplayProgressBar("Loading", "Fixing prefabs & assets", brokenAsset.Count / count); var projectAbsPath = Path.GetDirectoryName(Application.dataPath); var prefabAbsPath = projectAbsPath + "/" + prefabPath; string result = null; using (var streamReader = new StreamReader(prefabAbsPath)) { string scriptLine = ""; var text = streamReader.ReadToEnd(); var lines = text.Split('\n'); for (int i = 0; i < lines.Length; i++) { var line = lines[i]; if (line.StartsWith("---")) { scriptLine = ""; } if (line.StartsWith(" m_Script:")) { scriptLine = line; } if (scriptLine.Length > 0) { if (line.StartsWith(" m_Script:")) { var token = line.Split(','); try { int identifierIndex = 0; int guidIndex = 0; string identifier = null; string assetGuid = null; for (int x = 0; x < token.Length; x++) { var str = token[x]; if (str.StartsWith(" m_Script: {fileID:")) { identifierIndex = x; identifier = str.Replace(" m_Script: {fileID:", "").Trim(); } if (str.StartsWith(" guid:")) { guidIndex = x; assetGuid = str.Replace(" guid: ", ""); } } if (identifier != null && assetGuid != null) { if (string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(assetGuid))) { foreach (var a in missingMap) { if (a.Key.Equals(assetGuid) && a.Value.ContainsKey(identifier) && TypeSerializer.Deserialize(a.Value[identifier], false) != null) { Type t = TypeSerializer.Deserialize(a.Value[identifier], false); if (t == null) { continue; } MonoScript m = null; foreach (var s in uNodeEditorUtility.MonoScripts) { if (s.GetClass() == t) { m = s; break; } } if (m == null) { continue; } string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m)); if (!string.IsNullOrEmpty(guid)) { token[identifierIndex] = token[identifierIndex].Replace(identifier, ((long)Unsupported.GetLocalIdentifierInFileForPersistentObject(m)).ToString()); token[guidIndex] = token[guidIndex].Replace(assetGuid, guid); break; } break; } } } if (string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(assetGuid))) { foreach (var a in missingMap) { if (a.Key.Equals(assetGuid)) { if (a.Value.ContainsKey(identifier) && TypeSerializer.Deserialize(a.Value[identifier], false) != null) { } } } } lines[i] = string.Join(",", token); } } catch { } } } } result = string.Join("\n", lines); } if (!string.IsNullOrEmpty(result)) { File.WriteAllText(prefabAbsPath, result); AssetDatabase.Refresh(); } } } if (brokenScene != null) { int count = 0; foreach (var scene in brokenScene) { count++; EditorUtility.DisplayProgressBar("Loading", "Fixing scenes", brokenScene.Count / count); var p = AssetDatabase.GetAssetPath(scene); if (string.IsNullOrEmpty(p)) { continue; } var projectAbsPath = Path.GetDirectoryName(Application.dataPath); var prefabAbsPath = projectAbsPath + "/" + p; string result = null; using (var streamReader = new StreamReader(prefabAbsPath)) { var text = streamReader.ReadToEnd(); var lines = text.Split('\n'); string scriptLine = ""; for (int i = 0; i < lines.Length; i++) { var line = lines[i]; if (line.StartsWith("---")) { scriptLine = ""; } if (line.StartsWith("MonoBehaviour:")) { scriptLine = line; } if (scriptLine.Length > 0) { if (line.Trim().StartsWith("m_Script:")) { var token = line.Split(','); try { int identifierIndex = 0; int guidIndex = 0; string identifier = null; string assetGuid = null; for (int x = 0; x < token.Length; x++) { var str = token[x]; if (str.StartsWith(" m_Script: {fileID:")) { identifierIndex = x; identifier = str.Replace(" m_Script: {fileID:", "").Trim(); } if (str.StartsWith(" guid:")) { guidIndex = x; assetGuid = str.Replace(" guid: ", ""); } } if (identifier != null && assetGuid != null) { if (string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(assetGuid))) { foreach (var a in missingMap) { if (a.Key.Equals(assetGuid) && a.Value.ContainsKey(identifier) && TypeSerializer.Deserialize(a.Value[identifier], false) != null) { Type t = TypeSerializer.Deserialize(a.Value[identifier], false); if (t == null) { continue; } MonoScript m = null; foreach (var s in uNodeEditorUtility.MonoScripts) { if (s.GetClass() == t) { m = s; break; } } if (m == null) { continue; } string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m)); if (!string.IsNullOrEmpty(guid)) { token[identifierIndex] = token[identifierIndex].Replace(identifier, ((long)Unsupported.GetLocalIdentifierInFileForPersistentObject(m)).ToString()); token[guidIndex] = token[guidIndex].Replace(assetGuid, guid); break; } break; } } } if (string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(assetGuid))) { foreach (var a in missingMap) { if (a.Key.Equals(assetGuid)) { if (a.Value.ContainsKey(identifier) && TypeSerializer.Deserialize(a.Value[identifier], false) != null) { } } } } lines[i] = string.Join(",", token); } } catch { } } } } result = string.Join("\n", lines); } if (!string.IsNullOrEmpty(result)) { File.WriteAllText(prefabAbsPath, result); AssetDatabase.Refresh(); } } } missingMap = null; EditorUtility.ClearProgressBar(); }
static bool IsDynamicallyCreatedDuringLoad(GameObject gameObject) { return(Unsupported.GetFileIDHint(gameObject) == 0); }
public static SerializedObject GetSettingsObject(string className) { var settings = Unsupported.GetSerializedAssetInterfaceSingleton(className); return(new SerializedObject(settings)); }
public override void DrawView(Rect position) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); ProfilerAudioView newShowDetailedAudioPane = m_ShowDetailedAudioPane; if (AudioDeepProfileToggle()) { if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Channels, "Channels", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.Channels; } if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Groups, "Groups", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.Groups; } if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.ChannelsAndGroups, "Channels and groups", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.ChannelsAndGroups; } if (Unsupported.IsDeveloperMode() && GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.DSPGraph, "DSP Graph", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.DSPGraph; } if (Unsupported.IsDeveloperMode() && GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Clips, "Clips", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.Clips; } if (newShowDetailedAudioPane != m_ShowDetailedAudioPane) { m_ShowDetailedAudioPane = newShowDetailedAudioPane; m_LastAudioProfilerFrame = -1; // force update } if (m_ShowDetailedAudioPane == ProfilerAudioView.DSPGraph) { m_ShowInactiveDSPChains = GUILayout.Toggle(m_ShowInactiveDSPChains, "Show inactive", EditorStyles.toolbarButton); if (m_ShowInactiveDSPChains) { m_HighlightAudibleDSPChains = GUILayout.Toggle(m_HighlightAudibleDSPChains, "Highlight audible", EditorStyles.toolbarButton); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var graphRect = DrawAudioStatsPane(ref m_PaneScroll_AudioDSPLeft); m_PaneScroll_AudioDSPRight = GUI.BeginScrollView(graphRect, m_PaneScroll_AudioDSPRight, new Rect(0, 0, 10000, 20000)); var clippingRect = new Rect(m_PaneScroll_AudioDSPRight.x, m_PaneScroll_AudioDSPRight.y, graphRect.width, graphRect.height); if (m_AudioProfilerDSPView == null) { m_AudioProfilerDSPView = new AudioProfilerDSPView(); } ProfilerProperty property = m_ProfilerWindow.CreateProperty(); if (CheckFrameData(property)) { m_AudioProfilerDSPView.OnGUI(clippingRect, property, m_ShowInactiveDSPChains, m_HighlightAudibleDSPChains, ref m_DSPGraphZoomFactor, ref m_PaneScroll_AudioDSPRight); } if (property != null) { property.Dispose(); } GUI.EndScrollView(); m_ProfilerWindow.Repaint(); } else if (m_ShowDetailedAudioPane == ProfilerAudioView.Clips) { GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var treeRect = DrawAudioStatsPane(ref m_PaneScroll_AudioClips); // TREE if (m_AudioProfilerClipTreeViewState == null) { m_AudioProfilerClipTreeViewState = new AudioProfilerClipTreeViewState(); } if (m_AudioProfilerClipViewBackend == null) { m_AudioProfilerClipViewBackend = new AudioProfilerClipViewBackend(m_AudioProfilerClipTreeViewState); } ProfilerProperty property = m_ProfilerWindow.CreateProperty(); if (CheckFrameData(property)) { var currentFrame = m_ProfilerWindow.GetActiveVisibleFrameIndex(); if (currentFrame == -1 || m_LastAudioProfilerFrame != currentFrame) { m_LastAudioProfilerFrame = currentFrame; var sourceItems = property.GetAudioProfilerClipInfo(); if (sourceItems != null && sourceItems.Length > 0) { var items = new List <AudioProfilerClipInfoWrapper>(); foreach (var s in sourceItems) { items.Add(new AudioProfilerClipInfoWrapper(s, property.GetAudioProfilerNameByOffset(s.assetNameOffset))); } m_AudioProfilerClipViewBackend.SetData(items); if (m_AudioProfilerClipView == null) { m_AudioProfilerClipView = new AudioProfilerClipView(m_ProfilerWindow as EditorWindow, m_AudioProfilerClipTreeViewState); m_AudioProfilerClipView.Init(treeRect, m_AudioProfilerClipViewBackend); } } } if (m_AudioProfilerClipView != null) { m_AudioProfilerClipView.OnGUI(treeRect); } } if (property != null) { property.Dispose(); } } else { bool resetAllAudioClipPlayCountsOnPlay = GUILayout.Toggle(AudioUtil.resetAllAudioClipPlayCountsOnPlay, "Reset play count on play", EditorStyles.toolbarButton); if (resetAllAudioClipPlayCountsOnPlay != AudioUtil.resetAllAudioClipPlayCountsOnPlay) { AudioUtil.resetAllAudioClipPlayCountsOnPlay = resetAllAudioClipPlayCountsOnPlay; } if (Unsupported.IsDeveloperMode()) { GUILayout.Space(5); bool showAllGroups = EditorPrefs.GetBool("AudioProfilerShowAllGroups"); bool newShowAllGroups = GUILayout.Toggle(showAllGroups, "Show all groups (dev mode only)", EditorStyles.toolbarButton); if (showAllGroups != newShowAllGroups) { EditorPrefs.SetBool("AudioProfilerShowAllGroups", newShowAllGroups); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var treeRect = DrawAudioStatsPane(ref m_PaneScroll_AudioChannels); // TREE if (m_AudioProfilerGroupTreeViewState == null) { m_AudioProfilerGroupTreeViewState = new AudioProfilerGroupTreeViewState(); } if (m_AudioProfilerGroupViewBackend == null) { m_AudioProfilerGroupViewBackend = new AudioProfilerGroupViewBackend(m_AudioProfilerGroupTreeViewState); } ProfilerProperty property = m_ProfilerWindow.CreateProperty(); if (CheckFrameData(property)) { var currentFrame = m_ProfilerWindow.GetActiveVisibleFrameIndex(); if (currentFrame == -1 || m_LastAudioProfilerFrame != currentFrame) { m_LastAudioProfilerFrame = currentFrame; var sourceItems = property.GetAudioProfilerGroupInfo(); if (sourceItems != null && sourceItems.Length > 0) { var items = new List <AudioProfilerGroupInfoWrapper>(); foreach (var s in sourceItems) { bool isGroup = (s.flags & AudioProfilerGroupInfoHelper.AUDIOPROFILER_FLAGS_GROUP) != 0; if (m_ShowDetailedAudioPane == ProfilerAudioView.Channels && isGroup) { continue; } if (m_ShowDetailedAudioPane == ProfilerAudioView.Groups && !isGroup) { continue; } items.Add(new AudioProfilerGroupInfoWrapper(s, property.GetAudioProfilerNameByOffset(s.assetNameOffset), property.GetAudioProfilerNameByOffset(s.objectNameOffset), m_ShowDetailedAudioPane == ProfilerAudioView.Channels)); } m_AudioProfilerGroupViewBackend.SetData(items); if (m_AudioProfilerGroupView == null) { m_AudioProfilerGroupView = new AudioProfilerGroupView(m_ProfilerWindow as EditorWindow, m_AudioProfilerGroupTreeViewState); m_AudioProfilerGroupView.Init(treeRect, m_AudioProfilerGroupViewBackend); } } } if (m_AudioProfilerGroupView != null) { m_AudioProfilerGroupView.OnGUI(treeRect, m_ShowDetailedAudioPane == ProfilerAudioView.Channels); } } if (property != null) { property.Dispose(); } } } else { GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); DrawOverviewText(ProfilerArea.Audio, position); } }
public new void OnEnable() { base.OnEnable(); DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this; m_DebuggerSelection = new DebuggerSelection(); m_RepaintOverlay = new RepaintOverlayPainter(); m_PickOverlay = new HighlightOverlayPainter(); m_LayoutOverlay = new LayoutOverlayPainter(); var root = this.rootVisualElement; var sheet = EditorGUIUtility.Load(k_DefaultStyleSheetPath) as StyleSheet; root.styleSheets.Add(sheet); StyleSheet colorSheet; if (EditorGUIUtility.isProSkin) { colorSheet = EditorGUIUtility.Load(k_DefaultDarkStyleSheetPath) as StyleSheet; } else { colorSheet = EditorGUIUtility.Load(k_DefaultLightStyleSheetPath) as StyleSheet; } root.styleSheets.Add(colorSheet); root.Add(m_Toolbar); m_PickToggle = new ToolbarToggle() { name = "pickToggle" }; m_PickToggle.text = "Pick Element"; m_PickToggle.RegisterValueChangedCallback((e) => { m_PickElement = e.newValue; // On OSX, as focus-follow-mouse is not supported, // we explicitly focus the EditorWindow when enabling picking if (Application.platform == RuntimePlatform.OSXEditor) { Panel p = m_DebuggerSelection.panel as Panel; if (p != null) { TryFocusCorrespondingWindow(p); } } }); m_Toolbar.Add(m_PickToggle); m_ShowLayoutToggle = new ToolbarToggle() { name = "layoutToggle" }; m_ShowLayoutToggle.SetValueWithoutNotify(m_ShowLayoutBound); m_ShowLayoutToggle.text = "Show Layout"; m_ShowLayoutToggle.RegisterValueChangedCallback((e) => { m_ShowLayoutBound = e.newValue; panelDebug?.MarkDirtyRepaint(); panelDebug?.MarkDebugContainerDirtyRepaint(); }); m_Toolbar.Add(m_ShowLayoutToggle); if (Unsupported.IsDeveloperBuild()) { m_RepaintOverlayToggle = new ToolbarToggle() { name = "repaintOverlayToggle" }; m_RepaintOverlayToggle.text = "Repaint Overlay"; m_RepaintOverlayToggle.RegisterValueChangedCallback((e) => m_ShowRepaintOverlay = e.newValue); m_Toolbar.Add(m_RepaintOverlayToggle); m_UXMLLiveReloadToggle = new ToolbarToggle() { name = "UXMLReloadToggle" }; m_UXMLLiveReloadToggle.SetValueWithoutNotify(RetainedMode.UxmlLiveReloadIsEnabled); m_UXMLLiveReloadToggle.text = "UXML Live Reload"; m_UXMLLiveReloadToggle.RegisterValueChangedCallback((e) => RetainedMode.UxmlLiveReloadIsEnabled = e.newValue); m_Toolbar.Add(m_UXMLLiveReloadToggle); m_ShowDrawStatsToggle = new ToolbarToggle() { name = "drawStatsToggle" }; m_ShowDrawStatsToggle.text = "Draw Stats"; m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) => { var updater = (panel as BaseVisualElementPanel)?.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater; if (updater != null) { updater.DebugGetRenderChain().drawStats = e.newValue; } panelDebug?.MarkDirtyRepaint(); }); m_Toolbar.Add(m_ShowDrawStatsToggle); } var splitter = new DebuggerSplitter(); root.Add(splitter); m_TreeViewContainer = new DebuggerTreeView(m_DebuggerSelection, SelectElement); m_TreeViewContainer.style.flexGrow = 1f; splitter.leftPane.Add(m_TreeViewContainer); m_StylesDebuggerContainer = new StylesDebugger(m_DebuggerSelection); splitter.rightPane.Add(m_StylesDebuggerContainer); }
private void DrawControlPanel() { Builder builder = serializedObject.targetObject as Builder; if (builder == null) { return; } GUILayout.FlexibleSpace(); using (new EditorGUILayout.VerticalScope("box")) { GUILayout.Label( new GUIContent( $"{builder.productName} ver.{builder.version} ({builder.versionCode})", GetBuildTargetIcon(builder)), EditorStyles.largeLabel); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(new GUIContent("Apply Setting", EditorGUIUtility.FindTexture("vcs_check")))) { builder.ApplySettings(); } if (GUILayout.Button( new GUIContent("Player Setting", EditorGUIUtility.FindTexture("EditorSettings Icon")), GUILayout.Height(21), GUILayout.Width(110))) { Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings"); } } using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(new GUIContent("Build Addressable Assets", EditorGUIUtility.FindTexture("vcs_check")))) { Builder.BuildAddressableAssets(); } } EditorGUI.BeginDisabledGroup(builder.ActualBuildTarget != EditorUserBuildSettings.activeBuildTarget); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button( new GUIContent($"Build to '{builder.BuildName}'", EditorGUIUtility.FindTexture("preAudioPlayOff")), "LargeButton")) { EditorApplication.delayCall += () => BuilderUtil.StartBuild(builder, false); } var r = EditorGUILayout.GetControlRect(false, GUILayout.Width(15)); if (GUI.Button(new Rect(r.x - 2, r.y + 5, 20, 20), contentOpen, EditorStyles.label)) { BuilderUtil.RevealOutputInFinder(builder.OutputFolderPath); } EditorGUI.EndDisabledGroup(); } if (GUILayout.Button(new GUIContent("Build & Run", EditorGUIUtility.FindTexture("preAudioPlayOn")), "LargeButton")) { EditorApplication.delayCall += () => BuilderUtil.StartBuild(builder, true); } EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Convert to JSON (console log)")) { Debug.Log(JsonUtility.ToJson(builder, true)); } GUILayout.Space(10); GUILayout.Label("Available Project Builders", EditorStyles.boldLabel); roBuilderList.list = buildersInProject; roBuilderList.index = buildersInProject.FindIndex(x => x == serializedObject.targetObject); roBuilderList.DoLayoutList(); } }