protected virtual void OnGUI() { Rect r = this.position; r.x = 0F; r.y = 0F; r.yMax -= 32F; this.drawer.OnGUI(r); r.y += r.height; r.height = 32F; GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { GUILayout.Space(10F); using (LabelWidthRestorer.Get(95F)) { this.exportFile = NGEditorGUILayout.SaveFileField(LC.G("ExportFilePath"), this.exportFile, string.Empty, string.Empty); } } EditorGUILayout.EndVertical(); GUILayout.Space(10F); EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.exportFile)); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("Export"), GUILayoutOptionPool.Height(30F)) == true) { this.ExportLogs(); } } } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); }
protected virtual void OnGUI() { EditorGUI.BeginChangeCheck(); this.input = EditorGUILayout.TextField("Type", this.input); if (EditorGUI.EndChangeCheck() == true && this.input.Length > 2) { Utility.RegisterIntervalCallback(this.RefreshMatchingTypes, 100, 1); } Type t = Type.GetType(this.input); if (t != null) { if (GUILayout.Button("Analyze " + t.FullName)) { this.membersEmbedded.Clear(); this.type = t; this.fields = t.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); this.properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); this.methods = t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); for (int i = 0; i < this.fields.Length; i++) { if (this.SkipMember(this.fields[i]) == false) { this.membersEmbedded.Add(this.fields[i]); } } for (int i = 0; i < this.properties.Length; i++) { if (this.SkipMember(this.properties[i]) == false) { this.membersEmbedded.Add(this.properties[i]); } } for (int i = 0; i < this.methods.Length; i++) { if (this.methods[i].Name == "Finalize" || this.methods[i].Name == "GetHashCode" || this.methods[i].Name == "GetType" || this.methods[i].Name == "MemberwiseClone" || this.methods[i].Name == "ToString") { continue; } if (this.SkipMember(this.methods[i]) == false) { this.membersEmbedded.Add(this.methods[i]); } } } } this.scrollPositionAQN = EditorGUILayout.BeginScrollView(this.scrollPositionAQN, GUILayoutOptionPool.Height(Mathf.Min(this.matchingTypes.Count * 18F, 200F))); { for (int i = 0; i < this.matchingTypes.Count; i++) { if (GUILayout.Button(this.matchingTypes[i].FullName) == true) { this.input = this.matchingTypes[i].AssemblyQualifiedName; } } } EditorGUILayout.EndScrollView(); this.scrollPositionMembers = EditorGUILayout.BeginScrollView(this.scrollPositionMembers); { if (this.type != null) { if (string.IsNullOrEmpty(this.result) == false) { this.outputFilePath = NGEditorGUILayout.SaveFileField("File", this.outputFilePath); if (GUILayout.Button("Write to file") == true) { File.WriteAllText(this.outputFilePath, this.result); } if (GUILayout.Button("Copy to clipboard") == true) { EditorGUIUtility.systemCopyBuffer = this.result; } if (this.result.Length < short.MaxValue / 2) { EditorGUILayout.TextArea(this.result, GUILayout.MaxHeight(150F)); } else { EditorGUILayout.HelpBox("Result is too big to display.", MessageType.Warning); } } if (GUILayout.Button("Generate") == true) { this.Generate(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Fields (" + this.fields.Length + ")"); if (GUILayout.Button("Toggle") == true) { this.ToggleMembers(this.fields); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ++EditorGUI.indentLevel; this.DrawMembers(this.fields); --EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Properties (" + this.properties.Length + ")"); if (GUILayout.Button("Toggle") == true) { this.ToggleMembers(this.properties); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ++EditorGUI.indentLevel; this.DrawMembers(this.properties); --EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Methods (" + this.methods.Length + ")"); if (GUILayout.Button("Toggle") == true) { this.ToggleMembers(this.methods); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ++EditorGUI.indentLevel; this.DrawMembers(this.methods); --EditorGUI.indentLevel; } } EditorGUILayout.EndScrollView(); }
private void DrawProject() { GUILayout.Space(5F); EditorGUILayout.BeginVertical("ButtonLeft"); { this.openAutoRecovery = EditorGUILayout.Foldout(this.openAutoRecovery, "Recovery Settings (" + Enum.GetName(typeof(RecoveryMode), this.recoveryMode) + ")"); if (this.openAutoRecovery == true) { this.recoveryMode = (RecoveryMode)EditorGUILayout.EnumPopup("Recovery Mode", this.recoveryMode); if (this.recoveryMode == RecoveryMode.Automatic) { this.promptOnPause = EditorGUILayout.Toggle(this.promptOnPauseContent, this.promptOnPause); this.useCache = EditorGUILayout.Toggle(this.useCacheContent, this.useCache); this.supaFast = EditorGUILayout.Toggle(supaFastContent, this.supaFast); this.recoveryLogFilePath = NGEditorGUILayout.SaveFileField("Recovery Log File", this.recoveryLogFilePath); } GUILayout.Space(5F); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button("Scan", GeneralStyles.BigButton) == true) { string[] assets = AssetDatabase.GetAllAssetPaths(); this.hasResult = true; this.selectedMissing = -1; this.missings.Clear(); try { for (int i = 0; i < assets.Length; i++) { if (assets[i].EndsWith(".prefab") == false) { continue; } if (EditorUtility.DisplayCancelableProgressBar(NGMissingScriptRecoveryWindow.NormalTitle, "Scanning " + assets[i], (float)i / (float)assets.Length) == true) { break; } Object[] content = AssetDatabase.LoadAllAssetsAtPath(assets[i]); for (int j = 0; j < content.Length; j++) { GameObject go = content[j] as GameObject; if (go != null) { Component[] components = go.GetComponents <Component>(); for (int k = 0; k < components.Length; k++) { if (components[k] == null) { this.missings.Add(new MissingGameObject(go)); break; } } } } } } finally { EditorUtility.ClearProgressBar(); } return; } } GUILayout.FlexibleSpace(); if (this.cachedComponentFixes.Count > 0) { if (GUILayout.Button("Clear Recovery Cache (" + this.cachedComponentFixes.Count + " elements)", GeneralStyles.BigButton) == true) { this.cachedComponentFixes.Clear(); } } } EditorGUILayout.EndHorizontal(); if (this.hasResult == true) { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { GUILayout.Label("Result"); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true) { this.hasResult = false; } } EditorGUILayout.EndHorizontal(); if (this.missings.Count == 0) { GUILayout.Label("No missing script found."); } else { this.scrollPositionResult = EditorGUILayout.BeginScrollView(this.scrollPositionResult); { for (int i = 0; i < this.missings.Count; i++) { EditorGUILayout.BeginHorizontal(); { NGEditorGUILayout.PingObject(this.missings[i].path, this.missings[i].gameObject, GeneralStyles.LeftButton); if (GUILayout.Button("Fix", GUILayoutOptionPool.Width(75F)) == true) { this.selectedMissing = i; this.tab = 0; this.Diagnose(this.missings[i].gameObject); } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (this.recoveryMode == RecoveryMode.Automatic) { EditorGUILayout.HelpBox("Backup your project before\ndoing any automatic recovery.", MessageType.Warning); } using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { if (GUILayout.Button("Start Recovery", GeneralStyles.BigButton) == true) { Utility.StartBackgroundTask(this.RecoveryTask()); } } } EditorGUILayout.EndHorizontal(); } } }
public void DrawAssetImportParams(Rect r2, ImportAssetsWindow importAssetsWindow) { this.updateWindow = importAssetsWindow; //string gameObjectName = parameter.gameObjectName; //if (gameObjectName == null) // gameObjectName = parameter.gameObjectName = this.hierarchy.GetGameObjectName(parameter.gameObjectInstanceID); float w = r2.width; r2.height = Constants.SingleLineHeight; //Rect r2 = GUILayoutUtility.GetRect(22F, Constants.SingleLineHeight); bool canRemember = this.localAsset == null && this.isSupported == true; if (Event.current.type == EventType.MouseDown) { if (canRemember == true) { r2.width -= AssetImportParameters.RememberLabelWidth + AssetImportParameters.RememberSpacing + AssetImportParameters.LocationButtonWidth; } else { r2.width -= AssetImportParameters.LocationButtonWidth; } //if (r2.Contains(Event.current.mousePosition) == true) //{ // this.hierarchy.PingObject(this.gameObjectInstanceID); // Event.current.Use(); //} if (canRemember == true) { r2.width += AssetImportParameters.RememberLabelWidth + AssetImportParameters.RememberSpacing + AssetImportParameters.LocationButtonWidth; } else { r2.width += AssetImportParameters.LocationButtonWidth; } } GUI.Box(r2, string.Empty, GeneralStyles.Toolbar); //if (Event.current.type == EventType.Repaint) //{ // Rect r3 = r2; // r3.width = 1F; // r3.height = r3.height * 4F + 6F; // //EditorGUI.DrawRect(r3, Color.cyan); //} r2.width = ImportAssetsWindow.GameObjectIconWidth; GUI.DrawTexture(r2, AssetPreview.GetMiniTypeThumbnail(this.type), ScaleMode.ScaleToFit); r2.x += r2.width; string name = this.name ?? (this.name = this.hierarchy.GetResourceName(this.type, this.instanceID)); if (name == null) { GUI.Label(r2, GeneralStyles.StatusWheel); r2.x += r2.width; r2.width = w - r2.x; GUI.Label(r2, this.type.Name); importAssetsWindow.Repaint(); } else { r2.width = w - r2.x; GUI.Label(r2, this.type.Name + " : " + this.name); } r2.x = r2.width + ImportAssetsWindow.GameObjectIconWidth - AssetImportParameters.RememberLabelWidth - AssetImportParameters.RememberSpacing - AssetImportParameters.LocationButtonWidth; r2.width = AssetImportParameters.RememberLabelWidth; if (canRemember == true) { this.remember = GUI.Toggle(r2, this.remember, "Remember", GeneralStyles.ToolbarToggle); } r2.x += r2.width + AssetImportParameters.RememberSpacing; r2.width = AssetImportParameters.LocationButtonWidth; if (GUI.Button(r2, "Locations (" + this.originPath.Count + ")", GeneralStyles.ToolbarButton) == true) { PopupWindow.Show(r2, new AssetLocationsWindow(this.hierarchy, this.originPath)); //importAssets2.importingAssetsParams.Remove(this); } r2.y += r2.height + 2F; r2.x = 5F; r2.width = w - r2.x; using (LabelWidthRestorer.Get(120F)) { int pathsCount = this.originPath.Count; //if (pathsCount == 1) // EditorGUI.LabelField(r2, "Component Path", this.originPath[0]); //else if (pathsCount > 1) //{ // EditorGUI.LabelField(r2, "Component Path", string.Empty); // r2.xMin += EditorGUIUtility.labelWidth; // if (GUI.Button(r2, "Many (" + pathsCount + ")", GeneralStyles.ToolbarDropDown) == true) // { // } // r2.xMin -= EditorGUIUtility.labelWidth; //} r2.y += /*r2.height + */ 2F; if (this.localAsset != null) { EditorGUI.ObjectField(r2, "Asset", this.localAsset, this.type, false); } else if (this.isSupported == false) { r2.height = 24F; r2.xMin += 5F; r2.xMax -= 5F; EditorGUI.HelpBox(r2, "Not supported.", MessageType.Warning); } else { bool hasError = this.importMode == ImportMode.None; //EditorGUILayout.BeginHorizontal(); { using (LabelWidthRestorer.Get(100F)) { if (pathsCount > 0) { EditorGUI.BeginDisabledGroup(this.parametersConfirmed == true); { //r2.width = 182F/* - EditorGUI.indentLevel * 15F*/; this.importMode = (ImportMode)EditorGUI.EnumPopup(r2, "Import Mode", this.importMode); r2.y += r2.height; } EditorGUI.EndDisabledGroup(); } //EditorGUILayout.BeginVertical(); { EditorGUI.BeginDisabledGroup(this.parametersConfirmed == true); { if (this.importMode == ImportMode.Auto) { if (this.name == null) { this.name = this.hierarchy.GetResourceName(this.type, this.instanceID); } if (this.autoPath == null && this.name != null) { IObjectImporter importer = RemoteUtility.GetImportAssetTypeSupported(this.type); if (importer != null) { string path = this.prefabPath; string filename = string.Join("_", this.name.Split(Path.GetInvalidFileNameChars())) + importer.GetExtension(); if (string.IsNullOrEmpty(this.hierarchy.specificSharedSubFolder) == false) { path = this.hierarchy.specificSharedSubFolder; } //if (this.hierarchy.rawCopyAssetsToSubFolder == true) // path += "/" + .gameObjectName; //else if (this.hierarchy.prefixAsset == true) // filename = string.Join("_", (parameter.gameObjectName).Split(Path.GetInvalidFileNameChars())) + '_' + filename; this.autoPath = path + "/" + filename; } } if (/*parameter.gameObjectName != null && */ this.name != null) { if (this.autoPath == null) { r2.height = 24F; hasError = true; EditorGUI.HelpBox(r2, "Asset type is not supported, will not be imported.", MessageType.Warning); r2.y += r2.height; } else { EditorGUI.BeginChangeCheck(); this.autoPath = NGEditorGUILayout.SaveFileField(r2, "Output Path", this.autoPath); if (EditorGUI.EndChangeCheck() == true) { Uri pathUri; bool isValidUri = Uri.TryCreate(this.autoPath, UriKind.Relative, out pathUri); bool v = isValidUri && pathUri != null /* && pathUri.IsLoopback*/; //FileInfo fi = null; //try //{ // fi = new FileInfo(parameter.autoPath); //} //catch (System.ArgumentException) { } //catch (PathTooLongException) { } //catch (System.NotSupportedException) { } if (v == false) { //if (ReferenceEquals(fi, null)) this.autoPathError = "Path is invalid."; } // file name is not valid else { this.autoPathError = null; } // file name is valid... May check for existence by calling fi.Exists. } r2.y += r2.height; if (string.IsNullOrEmpty(this.autoPathError) == false) { r2.height = 24F; EditorGUI.HelpBox(r2, this.autoPathError, MessageType.Error); r2.y += r2.height; } } } else { Utility.content.text = "Waiting for server..."; EditorGUI.LabelField(r2, Utility.content, GeneralStyles.StatusWheel); r2.y += r2.height; importAssetsWindow.Repaint(); } } else if (this.importMode == ImportMode.UseGUID) { EditorGUI.BeginChangeCheck(); Object o = EditorGUI.ObjectField(r2, "Asset", this.guidAsset, this.type, false); if (EditorGUI.EndChangeCheck() == true) { this.guidAsset = o; this.guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o)); } r2.y += r2.height; EditorGUI.LabelField(r2, "GUID", this.guid ?? "None"); r2.y += r2.height; if (string.IsNullOrEmpty(this.guid) == true) { hasError = true; } } else if (this.importMode == ImportMode.RawCopy) { EditorGUI.BeginChangeCheck(); string path = NGEditorGUILayout.SaveFileField(r2, "Output Path", this.outputPath); if (EditorGUI.EndChangeCheck() == true) { if (path.StartsWith(Application.dataPath) == true) { this.outputPath = path.Substring(Application.dataPath.Length - "Assets".Length); } else if (path.StartsWith("Assets") == true) { this.outputPath = path; } } r2.y += r2.height; if (string.IsNullOrEmpty(path) == false && path.StartsWith(Application.dataPath) == false && path.StartsWith("Assets") == false) { hasError = true; r2.height = 24F; EditorGUI.HelpBox(r2, "Path must be in Assets folder.", MessageType.Warning); r2.y += r2.height; } } } EditorGUI.EndDisabledGroup(); r2.y += 2F; r2.height = Constants.SingleLineHeight; if (this.parametersConfirmed == true) { if (this.importErrorMessage != null) { r2.xMin += 5F; r2.height = 32F; EditorGUI.HelpBox(r2, "Import failed : " + this.importErrorMessage, MessageType.Error); } else if (this.copyAsset != null && (this.importMode == ImportMode.RawCopy || this.importMode == ImportMode.Auto)) { EditorGUI.ObjectField(r2, "Created Asset", this.copyAsset, this.type, false); } else if (this.totalBytes > 0) { r2.xMin += 5F; if (this.bytesReceived == this.totalBytes) { EditorGUI.ProgressBar(r2, 1F, "Creating asset..."); } else { float rate = (float)this.bytesReceived / (float)this.totalBytes; string cacheFileSize; if (this.totalBytes >= 1024 * 1024) { cacheFileSize = ((float)(this.bytesReceived / (1024F * 1024F))).ToString("N1") + " / " + ((float)(this.totalBytes / (1024F * 1024F))).ToString("N1") + " MiB"; } else if (this.totalBytes >= 1024) { cacheFileSize = ((float)(this.bytesReceived / 1024F)).ToString("N1") + " / " + ((float)(this.totalBytes / 1024F)).ToString("N1") + " KiB"; } else { cacheFileSize = this.bytesReceived + " / " + this.totalBytes + " B"; } EditorGUI.ProgressBar(r2, rate, cacheFileSize + " (" + (rate * 100F).ToString("0.0") + "%)"); importAssetsWindow.Repaint(); } } } else { EditorGUI.BeginDisabledGroup(hasError); { r2.width = 100F; r2.x = w - r2.width - 10F; if (GUI.Button(r2, "Confirm") == true) { this.Confirm(); importAssetsWindow.Repaint(); } } EditorGUI.EndDisabledGroup(); } } } if (Conf.DebugMode != Conf.DebugState.None && this.importErrorMessage != null && GUI.Button(r2, "Retry Import") == true) { this.ResetImport(); } } } } }