public override void OnInspectorGUI() { EditorGUILayout.LabelField("Performance example"); EditorGUILayout.LabelField("Increment an int"); EditorGUILayout.Space(); iterations = EditorGUILayout.IntField("Iterations ", iterations); EditorGUILayout.Space(); if (GUILayout.Button("Start Slow - WaitForSeconds 0.1f")) { EditorCoroutine.StartCoroutine(testCoroutine_slow()); } if (GUILayout.Button("Start Fast - return null")) { EditorCoroutine.StartCoroutine(testCoroutine_fast()); } if (GUILayout.Button("Stop")) { stop = true; } EditorGUILayout.Space(); EditorGUILayout.HelpBox("This function may freeze/crash your Unity instance!", MessageType.Warning); if (GUILayout.Button("Start iterator without EditorCoroutine")) { withoutCoroutine(); } EditorGUILayout.Space(); DrawDefaultInspector(); }
public void ParseConfig(string configPath) { var file = new FileInfo(configPath); if (!file.Exists) { throw new FileNotFoundException(); } var content = File.ReadAllText(configPath); var jsonNode = JSON.Parse(content); CurrentPsdName = jsonNode["name"].Value; var root = Extensions.NewGo("Root", null); root.AddMissingComponent <CanvasScaler>(); root.AddMissingComponent <GraphicRaycaster>(); var canvas = root.AddMissingComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; var layers = jsonNode["layers"].Children; Pivot = jsonNode["pivot"].ReadVector2(); var view = Extensions.NewGo(CurrentPsdName, root.transform); ViewParent = (RectTransform)view.transform; ViewParent.anchorMin = Vector2.zero; ViewParent.anchorMax = Vector2.one; ViewParent.pivot = Vector2.one * 0.5F; ViewParent.anchoredPosition3D = Vector3.zero; ViewParent.sizeDelta = Vector2.zero; EditorCoroutine.StartCoroutine(new EditorWaitForSeconds(0.1F, () => { try { var nodes = new List <LayerNode>(); var index = 0; //生成节点 GenerateLayers(layers, ViewParent); //处理节点关系 AdjustLayers(layers, ViewParent, nodes, ref index); //回调事件,更新节点 UpdateNode(nodes, ViewParent); } catch (Exception ex) { Debug.LogException(ex); UnityEngine.Object.DestroyImmediate(root); } })); }
static void A() { Debug.Log(DateTime.Now); EditorCoroutine.StartCoroutine(new EditorWaitForSeconds(3, () => { Debug.Log(DateTime.Now); })); }
public void ParseConfig(string content) { JSONNode jsonNode = null; try { jsonNode = JSON.Parse(content); } catch (Exception ex) { Debug.LogErrorFormat("配置读取失败!"); Debug.LogException(ex); return; } ModuleName = jsonNode["name"].Value; var rootName = "GUISystem"; var root = GameObject.Find(rootName); if (!root) { root = Extensions.NewGo("GUISystem", null); root.AddMissingComponent <CanvasScaler>(); root.AddMissingComponent <GraphicRaycaster>(); var canvas = root.AddMissingComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; } GUISystemRoot = (RectTransform)root.transform; var layers = jsonNode["layers"].Children; Pivot = jsonNode["pivot"].ReadVector2(); EditorCoroutine.StartCoroutine(new EditorWaitForSeconds(0.1F, () => { try { var nodes = new List <LayerNode>(); var index = 0; //生成节点 GenerateLayers(layers, GUISystemRoot); //处理节点关系 AdjustLayers(layers, GUISystemRoot, nodes, ref index); //回调事件,更新节点 UpdateNode(nodes, GUISystemRoot); } catch (Exception ex) { Debug.LogException(ex); UnityEngine.Object.DestroyImmediate(root); } })); }
public override void OnInspectorGUI() { if (GUILayout.Button("Start")) { EditorCoroutine.StartCoroutine(testCoroutine()); } EditorGUILayout.Space(); DrawDefaultInspector(); }
/// <summary> /// Runs the given tests /// </summary> public virtual void RunTests() { for (int i = 0; i < testToggles.Length; i++) { if (testToggles[i].selected) { Debug.Log(testToggles[i].toggleName); EditorCoroutine.StartCoroutine(testToggles[i].testToStart()); } } }
public static void TestZip() { string patchPacktUrl = "http://patch.xuebaogames.com/monster/1.0.0_1.0.6.zip"; HttpRequest httpRequest = new HttpRequest(); EditorCoroutine.StartCoroutine((httpRequest.Request(patchPacktUrl, (err, www) => { if (err != null) { Debug.Log(err); } else { byte[] bytes = www.bytes; MemoryStream ms = null; ZipFile zipFile = null; bool haveManifest = false; Manifest manifest = null; Dictionary <string, Asset> assetsMap = new Dictionary <string, Asset>(); try { ms = new MemoryStream(bytes); zipFile = ZipFile.Read(ms); //first is manifest file foreach (ZipEntry zipEntry in zipFile) { Debug.Log(zipEntry.Info); //Debug.Log(Path.Combine(Application.persistentDataPath, zipEntry.FileName)); zipEntry.Extract(Application.persistentDataPath, ExtractExistingFileAction.OverwriteSilently); } } finally { if (ms != null) { ms.Close(); } if (zipFile != null) { zipFile.Dispose(); } if (ms != null) { ms.Dispose(); } } } })), httpRequest); }
static EditorCoroutine Step() { if (!EditorApplication.isPlaying) { return(null); } return(EditorCoroutine.StartCoroutine(new EditorWaitForSeconds(mStepTime, () => { if (EditorApplication.isPaused && EditorApplication.isPlaying) { EditorApplication.Step(); mEditorCoroutine = Step(); } }))); }
public void DoSomething(bool start, bool stop, bool stopAll) { if (start) { EditorCoroutine.StartCoroutine(Example(), this); } if (stop) { EditorCoroutine.StopCoroutine("Example", this); } if (stopAll) { EditorCoroutine.StopAllCoroutines(this); } }
void OnGUI() { bunldeName = EditorGUILayout.TextField("Bundle Name:", bunldeName); EditorGUILayout.Space(); if (GUILayout.Button("Build Bundle")) { // init progress bar's values progress = 0; // do heavy IO process without blocking the display of progressbar EditorCoroutine.StartCoroutine(myHeavyJob()); } DisplayProgressBar(); }
public static void Init() { var asset = Resources.Load <TextAsset>(instance.fileName); if (asset == null) { #if UNITY_EDITOR EditorCoroutine.StartCoroutine(instance.LoadCoroutine(), instance); #endif } else { LoadDictionary(asset); LoadLanguage(); } }
public override void OnInspectorGUI() { if (GUILayout.Button("Open Spreadsheet")) { SG_Utils.OpenLink(localization.urlSpreadsheet); } GUILayout.Space(10); if (GUILayout.Button("Update")) { EditorCoroutine.StartCoroutine(localization.LoadCoroutine(), localization); } GUILayout.Space(10); base.OnInspectorGUI(); }
/// <summary> /// The Inspector of the Parent Class, call in override public void OnInspectorGUI() of the cild /// </summary> override public void OnInspectorGUI() { url = EditorGUILayout.TextField("URL: ", url); if (GUILayout.Button("Load values")) { if (!run) { run = true; EditorCoroutine.StartCoroutine(LoadFunction()); } } if (GUILayout.Button("Stop run")) { run = false; } EditorGUILayout.Space(); }
public void Play() { if (isPlaying) { return; } Reset(); isPlaying = true; StopAllCoroutines(); if (Application.isEditor && !Application.isPlaying) { EditorCoroutine.StartCoroutine(FpsStepper(), this); } else { StartCoroutine(FpsStepper()); } }
public static void StartCoroutine(this EditorWindow thisRef, string methodName, object value) { EditorCoroutine.StartCoroutine(methodName, value, thisRef); }
public static void StartCoroutine(this EditorWindow thisRef, IEnumerator coroutine) { EditorCoroutine.StartCoroutine(coroutine, thisRef); }
void OnGUI() { GUILayout.BeginVertical(); { GUILayout.Label("<b>TMP Project Files GUID Remapping Tool</b>", TMP_UIStyleManager.Section_Label); // Scan project files and resources GUILayout.BeginVertical(TMP_UIStyleManager.SquareAreaBox85G); { GUILayout.Label("<b>Scan Project Files</b>", TMP_UIStyleManager.Label); GUILayout.Label("Press the <i>Scan Project Files</i> button to begin scanning your project for files & resources that were created with a previous version of TextMesh Pro", TMP_UIStyleManager.Label); GUILayout.Space(5f); GUI.enabled = m_IsAlreadyScanningProject == false ? true : false; if (GUILayout.Button("Scan Project Files")) { // Make sure Asset Serialization mode is set to ForceText and Version Control mode to Visible Meta Files. if (CheckProjectSerializationAndSourceControlModes() == true) { EditorCoroutine.StartCoroutine(ScanProjectFiles()); } else { EditorUtility.DisplayDialog("Project Settings Change Required", "In menu options \"Edit - Project Settings - Editor\", please change Asset Serialization Mode to ForceText and Source Control Mode to Visible Meta Files.", "OK", string.Empty); } } GUI.enabled = true; // Display progress bar Rect rect = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true)); EditorGUI.ProgressBar(rect, m_ProgressPercentage, "Scan Progress (" + m_ScanningCurrentFileIndex + "/" + m_ScanningTotalFiles + ")"); GUILayout.Space(5); // Creation Feedback GUILayout.BeginVertical(TMP_UIStyleManager.TextAreaBoxWindow, GUILayout.ExpandHeight(true)); { m_ProjectScanResultScrollPosition = EditorGUILayout.BeginScrollView(m_ProjectScanResultScrollPosition, GUILayout.ExpandHeight(true)); EditorGUILayout.LabelField(m_ProjectScanResults, TMP_UIStyleManager.Label); EditorGUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.Space(5f); } GUILayout.EndVertical(); // Scan project files and resources GUILayout.BeginVertical(TMP_UIStyleManager.SquareAreaBox85G); { GUILayout.Label("<b>Save Modified Project Files</b>", TMP_UIStyleManager.Label); GUILayout.Label("Pressing the <i>Save Modified Project Files</i> button will update the files in the <i>Project Scan Results</i> listed above. <color=#FFFF80>Please make sure that you have created a backup of your project first</color> as these file modifications are permanent and cannot be undone.", TMP_UIStyleManager.Label); GUILayout.Space(5f); GUI.enabled = m_IsAlreadyScanningProject == false && m_ModifiedAssetList.Count > 0 ? true : false; if (GUILayout.Button("Save Modified Project Files")) { UpdateProjectFiles(); } GUILayout.Space(10f); } GUILayout.EndVertical(); } GUILayout.EndVertical(); GUILayout.Space(5f); }
void OnGUI() { GUILayout.BeginVertical(); { // Scan project files and resources GUILayout.BeginVertical(EditorStyles.helpBox); { GUILayout.Label("Scan Project Files", EditorStyles.boldLabel); GUILayout.Label("Press the <i>Scan Project Files</i> button to begin scanning your project for files & resources that were created with a previous version of TextMesh Pro.", TMP_UIStyleManager.label); GUILayout.Space(10f); GUILayout.Label("Project folder to be scanned. Example \"Assets/TextMesh Pro\""); m_ProjectFolderToScan = EditorGUILayout.TextField("Folder Path: Assets/", m_ProjectFolderToScan); GUILayout.Space(5f); GUI.enabled = m_IsAlreadyScanningProject == false ? true : false; if (GUILayout.Button("Scan Project Files")) { m_CancelScanProcess = false; // Make sure Asset Serialization mode is set to ForceText and Version Control mode to Visible Meta Files. if (CheckProjectSerializationAndSourceControlModes() == true) { EditorCoroutine.StartCoroutine(ScanProjectFiles()); } else { EditorUtility.DisplayDialog("Project Settings Change Required", "In menu options \"Edit - Project Settings - Editor\", please change Asset Serialization Mode to ForceText and Source Control Mode to Visible Meta Files.", "OK", string.Empty); } } GUI.enabled = true; // Display progress bar Rect rect = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true)); EditorGUI.ProgressBar(rect, m_ProgressPercentage, "Scan Progress (" + m_ScanningCurrentFileIndex + "/" + m_ScanningTotalFiles + ")"); // Display cancel button and name of file currently being scanned. if (m_IsAlreadyScanningProject) { Rect cancelRect = new Rect(rect.width - 20, rect.y + 2, 20, 16); if (GUI.Button(cancelRect, "X")) { m_CancelScanProcess = true; } GUILayout.Label("Scanning: " + m_ScanningCurrentFileName); } else { GUILayout.Label(string.Empty); } GUILayout.Space(5); // Creation Feedback GUILayout.BeginVertical(TMP_UIStyleManager.textAreaBoxWindow, GUILayout.ExpandHeight(true)); { m_ProjectScanResultScrollPosition = EditorGUILayout.BeginScrollView(m_ProjectScanResultScrollPosition, GUILayout.ExpandHeight(true)); EditorGUILayout.LabelField(m_ProjectScanResults, TMP_UIStyleManager.label); EditorGUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.Space(5f); } GUILayout.EndVertical(); // Scan project files and resources GUILayout.BeginVertical(EditorStyles.helpBox); { GUILayout.Label("Save Modified Project Files", EditorStyles.boldLabel); GUILayout.Label("Pressing the <i>Save Modified Project Files</i> button will update the files in the <i>Project Scan Results</i> listed above. <color=#FFFF80>Please make sure that you have created a backup of your project first</color> as these file modifications are permanent and cannot be undone.", TMP_UIStyleManager.label); GUILayout.Space(5f); GUI.enabled = m_IsAlreadyScanningProject == false && m_ModifiedAssetList.Count > 0 ? true : false; if (GUILayout.Button("Save Modified Project Files")) { UpdateProjectFiles(); } GUILayout.Space(10f); } GUILayout.EndVertical(); } GUILayout.EndVertical(); GUILayout.Space(5f); }