private void DrawControlButtons() { if (GUILayout.Button("Generate")) { if (genRoutine != null) { EditorCoroutineUtility.StopCoroutine(genRoutine); } genRoutine = EditorCoroutineUtility.StartCoroutine(generator.Generate(), generator); } }
public void Play() { if (dirtyTilemap == null) { state = new Algorithms.AlgorithmExecutionState(); dirtyTilemap = Instantiate(templateTilemap, templateTilemap.transform.parent); } running = true; coroutine = EditorCoroutineUtility.StartCoroutine(DoCheckCoroutine(), this); }
void StoreToBuildsystemServer() { List <PlatformData> datalist = PlatformDataManager.PlatformDataList.platformDatas; foreach (PlatformData data in datalist) { String jsonString = JsonUtility.ToJson(data); Debug.Log(jsonString); EditorCoroutineUtility.StartCoroutine(Upload(jsonString), this); } }
//COROUTINES IEnumerator LoadVersions() { EditorCoroutine coroutine; foreach (Package package in packageDatabase.GetPackages()) { coroutine = EditorCoroutineUtility.StartCoroutine(package.LoadAvailableVersions(), this); while (!package.isErrored && !package.isLoaded) { yield return(null); } } }
public override void OnInspectorGUI() { var go = Selection.activeGameObject; if (go != null) { var container = go.GetComponent <GeometryTargetingSystemsContainer>(); if (go.GetComponent <GeometryVision>() == null && container != null) { EditorCoroutineUtility.StartCoroutine(container.RemoveAddedComponents(), this); } } }
void LoadAllScenesCollectMaterial() { //save a backup copy SVCTool.ShaderUtils.SaveCurrentShaderVariantCollection("Assets/globalsvc_backup.shadervariants"); SVCTool.ShaderUtils.ClearCurrentShaderVariantCollection(); if (EditorApplication.isPlaying) { EditorApplication.ExitPlaymode(); } EditorCoroutineUtility.StartCoroutine(LoadAllEditorBuildScenes(), this); }
public override void OnGUI() { base.OnGUI(); GUILayout.Label("Create your own worlds and amaze other players! A sample world will help you to get started.", EditorStyles.wordWrappedLabel); EditorGUILayout.Space(); if (CheckTokenGUI()) { if (userWorlds == null || userWorlds.Length == 0) { EditorGUILayout.HelpBox("You have not registered any worlds yet on www.traVRsal.com.", MessageType.Info); } else { worldIdx = EditorGUILayout.Popup("Registered Worlds:", worldIdx, userWorlds.Select(w => w.key).ToArray()); worldName = userWorlds[worldIdx].key; if (GUILayout.Button("Create Selected World")) { CreateSampleWorld(); } } GUILayout.BeginHorizontal(); if (GUILayout.Button("Refresh List")) { EditorCoroutineUtility.StartCoroutine(FetchUserWorlds(), this); } if (GUILayout.Button("Register New")) { Help.BrowseURL("https://www.traVRsal.com/home"); } GUILayout.EndHorizontal(); } if (Directory.Exists(GetWorldsRoot(false))) { EditorGUILayout.Space(); showMaintenance = EditorGUILayout.Foldout(showMaintenance, "Maintenance Functions"); if (showMaintenance) { if (GUILayout.Button("Update/Restore Tiled Data")) { RestoreTiled(); } } } OnGUIDone(); }
public virtual IEnumerator MakeRoutine() { Terrain[] terrains = FindObjectsOfType <Terrain>(); for (int i = 0; i < terrains.Length; i++) { if (terrains[i].canBeErased && Contains(terrains[i])) { terrains[i].gameObject.SetActive(false); } } if (surroundWithTerrains) { Vector2 currentPoint; do { currentPoint = (Vector2)rootAreaPathNode.trs.position + (Random.insideUnitCircle.normalized * (rootAreaPathNode.radius + distToNodeForFirstTerrain)); yield return(new WaitForEndOfFrame()); } while (Contains(currentPoint)); yield return(EditorCoroutineUtility.StartCoroutine(MakeTerrainRoutine(currentPoint), this)); AreaPathNode[] uncheckedAreaPathNodes = new AreaPathNode[1] { rootAreaPathNode }; AreaPathNode[] deadEndAreaPathNodes = new AreaPathNode[0]; while (uncheckedAreaPathNodes.Length > 0) { if (uncheckedAreaPathNodes[0].gameObject.activeInHierarchy) { uncheckedAreaPathNodes = uncheckedAreaPathNodes.AddRange(uncheckedAreaPathNodes[0].children); if (uncheckedAreaPathNodes[0].children.Length == 0) { deadEndAreaPathNodes = deadEndAreaPathNodes.Add(uncheckedAreaPathNodes[0]); } } uncheckedAreaPathNodes = uncheckedAreaPathNodes.RemoveAt(0); } float normalizedTraversedDistance = 0; foreach (AreaPathNode deadEndAreaPathNode in deadEndAreaPathNodes) { do { currentPoint = GetPointAlongCenterPath(deadEndAreaPathNode, normalizedTraversedDistance + normalizedTraverseRate); DebugExtensions.DrawPoint(currentPoint, 10, Color.red, .1f); normalizedTraversedDistance = GetNormalizedDistanceOfClosestPointAlongCenterPath(deadEndAreaPathNode, currentPoint); yield return(new WaitForEndOfFrame()); } while (normalizedTraversedDistance < 1); } } }
void Update() { if (compare) { compare = false; if (textures.Count < 2) // not enough textures to compare { Debug.LogWarning("Not enough textures to compare."); return; } EditorCoroutineUtility.StartCoroutine(comparisonRoutine(), this); } }
public override void OnInspectorGUI() { // base.OnInspectorGUI(); BlockTerrain blockTerrain = (BlockTerrain)target; var data = blockTerrain.data; data = EditorGUILayout.ObjectField("Data", data, data.GetType()) as BlockTerrainData; data.name = EditorGUILayout.TextField("Name", data.name); EditorGUILayout.TextField("Version", data.version); data.width = EditorGUILayout.IntField("Wdith(X)", data.width); data.height = EditorGUILayout.IntField("Height(Y)", data.height); data.depth = EditorGUILayout.IntField("Depth(Z)", data.depth); GUILayout.BeginHorizontal(); if (GUILayout.Button("创建地形", (GUIStyle)"ButtonLeft")) { //创建map的chunks MyTools.DeleteAllChildren(blockTerrain.transform); InitTerrainData(); EditorCoroutineUtility.StartCoroutine(blockTerrain.LoadTerrainAsyn(), this); } if (GUILayout.Button("清空Mesh缓存", (GUIStyle)"ButtonMid")) { //创建map的chunks MyTools.DeleteAllChildren(blockTerrain.transform); } if (GUILayout.Button("更新Mesh", (GUIStyle)"ButtonRight")) { //blockTerrain.CreateRandomMap(); } GUILayout.EndHorizontal(); selectPanelIndex = GUILayout.Toolbar(selectPanelIndex, panelNames); if (panelNames[selectPanelIndex] == "笔刷") { this.DrawBrushesPanel(data); } else if (panelNames[selectPanelIndex] == "图块") { this.DrawBlocksPanel(data); } else if (panelNames[selectPanelIndex] == "图层") { this.DrawLayersPanel(data); } else if (panelNames[selectPanelIndex] == "设置") { } }
private void Preview() { EditorUtility.audioMasterMute = false; if (clip == null) { Debug.LogError($"Clip previewing is empty!"); return; } var source = CreateObjectWithAudioSource(); SetUpValues(source); source.Play(); EditorCoroutineUtility.StartCoroutine(DestroyEditor(clip.length, source.gameObject), this); }
public void UploadBuild(ButlerSettings settings) { IsUploading = true; EditorCoroutineUtility.StartCoroutine(ButlerCommandRoutine(settings.ToPushArgs(), (success, error) => { IsUploading = false; Application.OpenURL(settings.GetURL()); if (success) { AppendConsoleMessage?.Invoke("Upload Complete."); } else { AppendConsoleMessage?.Invoke(error); } }), this); }
public void BuildLightingScenario(SceneAsset scene) { //Remove reference to LightingDataAsset so that Unity doesn't delete the previous bake Lightmapping.lightingDataAsset = null; Debug.Log("Loading " + scene.name); string lightingScenePath = AssetDatabase.GetAssetOrScenePath(scene); Scene lightingScene = EditorSceneManager.OpenScene(lightingScenePath, OpenSceneMode.Additive); EditorSceneManager.SetActiveScene(lightingScene); SearchLightsNeededRealtime(); Debug.Log("Start baking"); EditorCoroutineUtility.StartCoroutine(BuildLightingAsync(lightingScene), this); }
public static void PlaySoundInEditor(SoundData _soundData) { #if UNITY_EDITOR if (_soundData.delay > 0) { if (soundCoroutine != null) { EditorCoroutineUtility.StopCoroutine(soundCoroutine); } soundCoroutine = EditorCoroutineUtility.StartCoroutine(PlaySoundInEditor_C(GetSoundClip(_soundData), 0, false, _soundData.delay), _soundData); } else { PlaySoundInEditor(GetSoundClip(_soundData)); } #endif }
public IEnumerator CreateNew(int size, int splat, int biome) { yield return(EditorCoroutineUtility.StartCoroutine(Cleanup(), this)); ActionProgressBar.UpdateProgress("Creating New World Data...", 0f); yield return(null); yield return(null); world = World.NewDataFromSize(size, splat, biome); EditorCoroutineUtility.StartCoroutine(LoadMap(world), this); ActionProgressBar.Close(); Debug.Log("World Loaded!"); }
/// <summary> /// 只有两种情况会调用到这个函数 /// 1.打开GraphEditorWindow(初次打开或者在已经打开的基础上更换GraphAsset) /// 2.编译/进入PlayMode而导致的GraphEditorWindow重载 /// </summary> /// <param name="graph"></param> public void InitializeGraph(BaseGraph graph) { if (this.graph != null && graph != this.graph) { // Save the graph to the disk GraphCreateAndSaveHelper.SaveGraphToDisk(this.graph); // Unload the graph graphUnloaded?.Invoke(this.graph); } graphLoaded?.Invoke(graph); this.graph = graph; if (graphView != null) { rootView.Remove(graphView); } InitializeWindow(graph); rootView.Add(graphView); graphView = rootView.Children().FirstOrDefault(e => e is BaseGraphView) as BaseGraphView; if (graphView == null) { Debug.LogError("GraphView has not been added to the BaseGraph root view !"); return; } EditorCoroutineUtility.StartCoroutine(graphView.Initialize(graph), this); InitializeGraphView(graphView); // TOOD: onSceneLinked... if (graph.IsLinkedToScene()) { LinkGraphWindowToScene(graph.GetLinkedScene()); } else { graph.onSceneLinked += LinkGraphWindowToScene; } //防止在外部调用InitializeGraph时重复执行InitializeGraph reloadWorkaround = false; }
//---------------------------------------------------------------------------------------------------------------------- private void DrawUpdateRenderCacheGUI() { ShortcutBinding updateRenderCacheShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_UPDATE_RENDER_CACHE); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig(); bool captureAllFrames = EditorGUILayout.Toggle("Capture All Frames", editorConfig.GetCaptureAllFrames()); editorConfig.SetCaptureAllFrames(captureAllFrames); EditorGUI.BeginDisabledGroup(captureAllFrames); ++EditorGUI.indentLevel; int captureStartFrame = Math.Max(0, editorConfig.GetCaptureStartFrame()); int captureEndFrame = editorConfig.GetCaptureEndFrame(); if (captureEndFrame < 0) { captureEndFrame = TimelineUtility.CalculateNumFrames(TimelineEditor.selectedClip); } editorConfig.SetCaptureStartFrame(EditorGUILayout.IntField("From", captureStartFrame)); editorConfig.SetCaptureEndFrame(EditorGUILayout.IntField("To", captureEndFrame)); --EditorGUI.indentLevel; EditorGUI.EndDisabledGroup(); GUILayout.Space(10); if (GUILayout.Button($"Update Render Cache ({updateRenderCacheShortcut})")) { PlayableDirector director = TimelineEditor.inspectedDirector; if (null == director) { EditorUtility.DisplayDialog("Streaming Image Sequence", "PlayableAsset is not loaded in scene. Please load the correct scene before doing this operation.", "Ok"); return; } //Loop time EditorCoroutineUtility.StartCoroutine(UpdateRenderCacheCoroutine(director, m_asset), this); } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUI.BeginDisabledGroup(busy || string.IsNullOrEmpty(m_target.apiKey) || string.IsNullOrEmpty(m_target.database_id)); if (GUILayout.Button("Fetch Schema")) { var api = new NotionAPI(m_target.apiKey); busy = true; EditorCoroutineUtility.StartCoroutine(api.GetDatabaseJSON(m_target.database_id, (db) => { Debug.Log(db); Undo.RecordObject(m_target, "Update Schema"); var json = JSON.Parse(db); m_target.fieldNames.Clear(); m_target.fieldTypes.Clear(); foreach (var node in json["properties"]) { m_target.fieldNames.Add(node.Key); m_target.fieldTypes.Add(node.Value["type"]); } EditorUtility.SetDirty(m_target); busy = false; }), this); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(busy || m_target.fieldNames == null || m_target.fieldNames.Count == 0); if (GUILayout.Button("Create Schema Class")) { CreateCodeSchemaFile(m_target); } if (GUILayout.Button("Create Serialized Database Asset")) { CreateSerializedDatabaseFile(m_target); } EditorGUI.EndDisabledGroup(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var settings = (VersionSettings)target; GUILayout.BeginHorizontal(); if (GUILayout.Button("Fetch")) { EditorCoroutineUtility.StartCoroutine(FetchVersion(settings), this); } if (GUILayout.Button("Set")) { EditorCoroutineUtility.StartCoroutine(UpdateVersion(settings), this); } GUILayout.EndHorizontal(); }
public static Texture LoadImageAsync(string imageUrl, Texture2D defaultIcon, EditorWindow editor) { if (string.IsNullOrEmpty(imageUrl)) { Debug.LogWarning($"imageUrl is null or empty"); return(defaultIcon); } if (_inMemoryCache.TryGetValue(imageUrl, out var image)) { return(image); } _inMemoryCache.Add(imageUrl, defaultIcon); EditorCoroutineUtility.StartCoroutine(LoadImageInternalAsync(imageUrl, editor), editor); return(defaultIcon); }
public static void Init() { if (window != null) { window.Close(); } UpdateGitInfo(); window = CreateInstance <AutomatedBuild>(); window.position = new Rect(Screen.width / 2, Screen.height / 2, 400, 155); window.Repaint(); window.ShowPopup(); if (periodicUpdateRoutine == null) { periodicUpdateRoutine = EditorCoroutineUtility.StartCoroutine(instance.PeriodicUpdateGitInfo(), instance); } }
IEnumerator GameCoreRunner() { Init(); //Infinite Game Cycle while (isGaming) { //Spawn Player Shape playerShape = new PlayerShape(); playerShape.shapeCoordinates = TetrisShapes.GetShapeCoordinates(TetrisShapes.Shape.Random); playerShape.shapeCoordinates += new Coordinate(Mathf.RoundToInt(gameSize.x / 2), gameSize.y - 2); if (DetectIfCollideWithGameBoard(playerShape.shapeCoordinates)) { yield return(EditorCoroutineUtility.StartCoroutine(GameOverProcess(), ArcadeWindow.instance)); yield break; } double t = 0; while (playerShape != null) { t += deltaTime; if (t > FallFrequency) { t -= FallFrequency; t %= FallFrequency; FallDownPlayer(); } yield return(null); } BlockState[,] newBlockStates; bool isAnyMatchedLines = CheckMatch(out newBlockStates); gameBoard = newBlockStates; if (isAnyMatchedLines) { yield return(new EditorWaitForSeconds(1f)); ClearLine(); } } }
private void OnGUI() { if (Directory.Exists(Application.dataPath + "/Temp/")) { Directory.Delete(Application.dataPath + "/Temp/", true); } foreach (string k in download.Keys) { if (download[k].Filetype.Contains("zip")) { if (GUILayout.Button("Download " + k)) { WebClient wc = new WebClient(); Directory.CreateDirectory(Application.dataPath + "/Temp/"); wc.DownloadFile(download[k].RawDownloadLink, Application.dataPath + "/Temp/downloadTex.zip"); wc.Dispose(); Directory.CreateDirectory(Application.dataPath + "/Materials/Textures"); var zf = ZipFile.Read(Application.dataPath + "/Temp/downloadTex.zip"); zf.ExtractAll(Application.dataPath + "/Temp"); zf.Dispose(); string[] textureFiles = Directory.GetFiles(Application.dataPath + "/Temp").Where(x => { return(x.Contains("_")); }).ToArray(); string texName = Path.GetFileName(textureFiles[0]).Split('_')[0]; string ext = Path.GetExtension(textureFiles[0]); string res = Path.GetFileName(textureFiles[0]).Split('_')[1]; foreach (string f in textureFiles) { if (!File.Exists(Application.dataPath + "/Materials/Textures/" + Path.GetFileName(f))) { File.Move(f, Application.dataPath + "/Materials/Textures/" + Path.GetFileName(f)); } } this.Close(); EditorCoroutineUtility.StartCoroutine(StartImport(texName, res, ext), this); } } } }
private void Run() { while (SystemManager.Instance.Connect) { Thread.Sleep(33); EditorCoroutineUtility.StartCoroutine(DeviceControl(), this); if (bWaitThread) { continue; } if (nImgFrameIDX >= nMaxImageIndex) { Init(); break; } EditorCoroutineUtility.StartCoroutine(MappingCoroutine(), this); } }
public virtual void OnEnable() { string logoName = EditorGUIUtility.isProSkin ? "travrsal-white-300.png" : "travrsal-300.png"; Texture2D logoImage = AssetDatabase.LoadAssetAtPath($"Packages/com.wetzold.travrsal.sdk/Editor/Images/{logoName}", typeof(Texture2D)) as Texture2D; if (logoImage == null) { logoImage = AssetDatabase.LoadAssetAtPath($"Assets/SDK/Editor/Images/{logoName}", typeof(Texture2D)) as Texture2D; } logo = new GUIStyle { normal = { background = logoImage }, fixedWidth = 128, fixedHeight = 64 }; // perform (cheap) setup tasks SetupTags(); EditorCoroutineUtility.StartCoroutine(FetchUserWorlds(), this); }
private void DrawSnapshotPanel() { SpiralEditor.BeginPanel("Last snapshot preview"); SpiralEditor.SetGUIEnabled(false); SpiralEditor.DrawObjectField("Snapshot", lastSnapshot, false); if (lastSnapshot != null) { SpiralEditor.BoldLabel($"{lastSnapshot.width}x{lastSnapshot.height}", true); } SpiralEditor.RestoreGUIEnabled(); bool snapShotEnabled = GameViewUtils.gameView != null && !waiting; SpiralEditor.SetGUIEnabled(snapShotEnabled); try { bool makescreen = SpiralEditor.CenteredButton("Make a photo"); if (makescreen) { EditorCoroutineUtility.StartCoroutine(WaitForEditor(), this); } } catch { SpiralEditor.EndPanel(); return; } // welcome to the silence null SpiralEditor.RestoreGUIEnabled(); if (!snapShotEnabled) { if (waiting) { SpiralEditor.MessagePanel("Wait...", MessageType.Info); } else { SpiralEditor.MessagePanel("If disabled, try to open or restart GameView", MessageType.Warning); } } SpiralEditor.EndPanel(); }
private IEnumerator LoadMap(string filename) { yield return(EditorCoroutineUtility.StartCoroutine(Cleanup(), this)); WorldSerialization blob = new WorldSerialization(); ActionProgressBar.UpdateProgress("Loading Map...", 0f); yield return(null); yield return(null); blob.Load(filename); world = World.WorldToTerrain(blob); yield return(EditorCoroutineUtility.StartCoroutine(LoadMap(world), this)); ActionProgressBar.Close(); Debug.Log("World Loaded!"); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(geometrySceneName); EditorGUILayout.PropertyField(lightingSceneName); EditorGUILayout.PropertyField(storeRendererInfos); EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Stored Data", EditorStyles.boldLabel); //Begin disabled group as this is a data summary display EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(lightmapsMode); EditorGUILayout.TextField("Lightmaps count", lightmaps.arraySize.ToString()); EditorGUILayout.TextField("Renderer Infos count", rendererInfos.arraySize.ToString()); EditorGUILayout.ObjectField(lightProbes); EditorGUILayout.PropertyField(hasRealtimeLights); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); LightingScenarioData scenarioData = (LightingScenarioData)target; if (GUILayout.Button("Generate lighting scenario data")) { LoadLightingScenarioScenes(scenarioData); //Check if the lighting scene needs requires dynamic lighting ( if not, never try to load the lighting scene ). scenarioData.hasRealtimeLights = SearchLightsNeededRealtime(); Debug.Log("Lightmap switcher - Start baking"); //Remove reference to LightingDataAsset so that Unity doesn't delete the previous bake Lightmapping.lightingDataAsset = null; EditorCoroutineUtility.StartCoroutine(BuildLightingAsync(scenarioData), this); } if (GUILayout.Button("Load Lighting scenario")) { LoadLightingScenarioScenes(scenarioData); GameObject.FindObjectOfType <LevelLightmapData>().LoadLightingScenarioData(scenarioData); } serializedObject.ApplyModifiedProperties(); }
private static void OnToolbarGUI() { if (!initialized) { Initialize(); } GUILayout.FlexibleSpace(); if (GUILayout.Button(content, style)) { Debug.Log("Start hashing files, this may take a while."); InitDatabase(); InitGoogleService(); if (EditorPrefs.HasKey("kAutoRefresh")) { EditorPrefs.SetBool("kAutoRefresh", false); } EditorCoroutineUtility.StartCoroutine(FetchCoroutine(FolderId, TexturesPath), Instance); FetchTasks.TryAdd(FolderId, false); EditorCoroutineUtility.StartCoroutine(TaskMonitor(), Instance); } }
protected bool CheckTokenGUI() { if (string.IsNullOrEmpty(GetAPIToken())) { EditorGUILayout.HelpBox("You have not entered your Creator Key yet. Please do so in the Project Settings. You can find your personal key on www.traVRsal.com.", MessageType.Error); if (GUILayout.Button("Visit traVRsal.com")) { Help.BrowseURL("https://www.traVRsal.com/home"); } return(false); } if (SDKUtil.invalidAPIToken) { EditorGUILayout.HelpBox("Your Creator Key is invalid or expired. Please update it in the Project Settings. You can find your personal key on www.traVRsal.com.", MessageType.Error); if (GUILayout.Button("Retry")) { EditorCoroutineUtility.StartCoroutine(FetchUserWorlds(), this); } if (GUILayout.Button("Visit traVRsal.com")) { Help.BrowseURL("https://www.traVRsal.com/home"); } return(false); } if (SDKUtil.networkIssue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("There are issues connecting to the server.", MessageType.Error); if (GUILayout.Button("Retry")) { EditorCoroutineUtility.StartCoroutine(FetchUserWorlds(), this); } return(false); } return(true); }