private static void FetchWorlds(int offset = 0) { ApiWorld.FetchList( delegate(IEnumerable <ApiWorld> obj) { if (obj.FirstOrDefault() != null) { fetchingWorlds = EditorCoroutine.Start(() => { var l = obj.ToList(); int count = l.Count; SetupWorldData(l); FetchWorlds(offset + count); }); } else { fetchingWorlds = null; foreach (ApiWorld w in uploadedWorlds) { DownloadImage(w.id, w.thumbnailImageUrl); } } }, delegate(string obj) { Debug.LogError("Error fetching your uploaded worlds:\n" + obj); fetchingWorlds = null; }, ApiWorld.SortHeading.Updated, ApiWorld.SortOwnership.Mine, ApiWorld.SortOrder.Descending, offset, PageLimit, "", null, null, null, "", ApiWorld.ReleaseStatus.All, null, null, true, false); }
static void FetchAvatars(int offset = 0) { ApiAvatar.FetchList( delegate(IEnumerable <ApiAvatar> obj) { Debug.LogFormat("<color=yellow>Fetching Avatar Bucket {0}</color>", offset); if (obj.FirstOrDefault() != null) { fetchingAvatars = EditorCoroutine.Start(() => { var l = obj.ToList(); int count = l.Count; SetupAvatarData(l); FetchAvatars(offset + count); }); } else { fetchingAvatars = null; foreach (ApiAvatar a in uploadedAvatars) { DownloadImage(a.id, a.thumbnailImageUrl); } } }, delegate(string obj) { Debug.LogError("Error fetching your uploaded avatars:\n" + obj); fetchingAvatars = null; }, ApiAvatar.Owner.Mine, ApiAvatar.ReleaseStatus.All, null, PageLimit, offset, ApiAvatar.SortHeading.None, ApiAvatar.SortOrder.Descending, null, null, true, false, null, false ); }
void Update() { if (APIUser.IsLoggedInWithCredentials && (uploadedWorlds == null || uploadedAvatars == null)) { if (uploadedWorlds == null) { uploadedWorlds = new List <ApiWorld>(); } if (uploadedAvatars == null) { uploadedAvatars = new List <ApiAvatar>(); } EditorCoroutine.Start(window.FetchUploadedData()); } Repaint(); }
static void FetchWorlds(int offset = 0) { ApiWorld.FetchList( delegate(List <ApiWorld> obj) { Debug.LogFormat("<color=yellow>Fetching World Bucket {0}</color>", offset); if (obj.Count > 0) { fetchingWorlds = EditorCoroutine.Start(() => { int count = obj.Count; SetupWorldData(obj); FetchWorlds(offset + count); }); } else { fetchingWorlds = null; foreach (ApiWorld w in uploadedWorlds) { DownloadImage(w.id, w.thumbnailImageUrl); } } }, delegate(string obj) { Debug.LogError("Error fetching your uploaded worlds:\n" + obj); fetchingWorlds = null; }, ApiWorld.SortHeading.Updated, ApiWorld.SortOwnership.Mine, ApiWorld.SortOrder.Descending, offset, PageLimit, "", null, null, null, "", ApiWorld.ReleaseStatus.All, false, true); }
public override void OnGUI() { base.OnGUI(); GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { GUILayout.Label("定时器,定时10秒,每0.5秒一次回调"); GUILayout.Label(count.ToString()); if (GUILayout.Button("Start")) { EditorCoroutine.Start(Timer()); } } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Label("等待 定时器 >5"); if (GUILayout.Button("Start")) { EditorCoroutine.Start(waitCounting()); } GUILayout.Label(!countend ? "等待中.." : "✓"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Label("等1帧"); if (GUILayout.Button("Start")) { EditorCoroutine.Start(waitForNextFrame()); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (GUILayout.Button("整合两个携程的序列")) { EditorCoroutine.Start(sequnce()); } OnGUIUtility.ScriptField("Script", this.GetType()); }
public void DrawGUI() { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Calculate prime numbers"); numPrimes = EditorGUILayout.IntField("Stop After", numPrimes); numPrimes = Mathf.Clamp(numPrimes, 100, 100000); if (runningRoutine == null || runningRoutine.State == EditorCoroutineState.Canceled || runningRoutine.State == EditorCoroutineState.Done) { if (GUILayout.Button("Start")) { runningRoutine = EditorCoroutine.Start(FindPrimeNumber(numPrimes)); } } else { if (runningRoutine != null && GUILayout.Button("Cancel")) { runningRoutine.Cancel(); } } if (runningRoutine != null) { var prevColor = GUI.backgroundColor; switch (runningRoutine.State) { case EditorCoroutineState.Running: GUI.backgroundColor = Color.yellow; break; case EditorCoroutineState.Canceled: GUI.backgroundColor = Color.red; break; case EditorCoroutineState.Done: GUI.backgroundColor = Color.green; break; } EditorGUILayout.LabelField(runningRoutine.State.ToString(), EditorStyles.helpBox); GUI.backgroundColor = prevColor; } EditorGUILayout.EndVertical(); }
public void GetLaunchingInfo <T>(LaunchingConfigurations launchingConfigurations, Action <T> callback) { var request = UnityWebRequest.Get( string.Format("{0}/{1}/appkeys/{2}/configurations", launchingConfigurations.uri, launchingConfigurations.version, launchingConfigurations.appKey)); request.method = UnityWebRequest.kHttpVerbGET; var helper = new UnityWebRequestHelper(request); EditorCoroutine.Start( helper.SendWebRequest( (result) => { var launchingInfo = JsonUtility.FromJson <T>(result.downloadHandler.text); callback(launchingInfo); })); }
static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths ) { if (isPostProcessing) { return; } isPostProcessing = true; bool anyDirty = false; using (var dirtyPrefabs = TempList <GameObject> .Get()) { PostProcessAssets(importedAssets, dirtyPrefabs.buffer); anyDirty = dirtyPrefabs.Count > 0; for (int i = 0; i < dirtyPrefabs.Count; ++i) { GameObject prefab = dirtyPrefabs[i]; EditorUtility.SetDirty(prefab); } UpdateSceneObjects(dirtyPrefabs.buffer); } if (anyDirty) { EditorCoroutine.Start(SaveProjectAndWaitForFrame()); } else { isPostProcessing = false; } }
void ShowContent() { if (uploadedWorlds == null || uploadedAvatars == null) { if (uploadedWorlds == null) { uploadedWorlds = new List <ApiWorld>(); } if (uploadedAvatars == null) { uploadedAvatars = new List <ApiAvatar>(); } EditorCoroutine.Start(FetchUploadedData()); } if (fetchingWorlds != null || fetchingAvatars != null) { GUILayout.BeginVertical(boxGuiStyle, GUILayout.Width(SdkWindowWidth)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Fetching Records", titleGuiStyle); EditorGUILayout.Space(); GUILayout.EndVertical(); } else { GUILayout.BeginVertical(boxGuiStyle, GUILayout.Width(SdkWindowWidth)); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Fetch updated records from the VRChat server"); if (GUILayout.Button("Fetch")) { ClearContent(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.EndVertical(); } OnGUIUserInfo(); }
IEnumerator PatchVenue() { isProcessing = true; isUploading = false; if (!string.IsNullOrEmpty(thumbnailImagePath)) { var uploadThumbnail = new UploadThumbnailService( accessToken, thumbnailImagePath, policy => { isUploading = false; payload.thumbnailUrls = new List <ThumbnailUrl>() { new ThumbnailUrl(policy.url) }; }, exception => { isUploading = false; HandleError(exception); } ); isUploading = true; uploadThumbnail.Run(); while (isUploading) { yield return(null); } if (!isProcessing) { yield break; } } EditorCoroutine.Start(PatchVenueCore()); }
private static string CheckForPlatformUtil(string dataPath) { string toolDataPath = dataPath + "/Oculus/VR/Editor/Tools"; if (!Directory.Exists(toolDataPath)) { Directory.CreateDirectory(toolDataPath); } string platformUtil = toolDataPath + "/ovr-platform-util.exe"; if (!System.IO.File.Exists(platformUtil)) { OVRPlugin.SendEvent("oculus_platform_tool", "provision_util"); EditorCoroutine downloadCoroutine = EditorCoroutine.Start(ProvisionPlatformUtil(platformUtil)); while (!downloadCoroutine.GetCompleted()) { } } return(platformUtil); }
private static void CompleteImportMappings(string mappingsPath) { EditorPrefs.DeleteKey("RTSL_ImportMappings"); PersistentClassMapping[] classMappings = null; PersistentClassMapping[] surrogateMappings = null; try { MappingsUtility.Import(mappingsPath, out classMappings, out surrogateMappings); MappingsUtility.MergeClassMappings(classMappings); MappingsUtility.MergeSurrogateMappings(surrogateMappings); } finally { Cleanup(classMappings); Cleanup(surrogateMappings); File.Delete(mappingsPath); File.Delete(mappingsPath + ".meta"); } EditorCoroutine.Start(CoBuildAll()); }
private IEnumerator SendLogPolling() { while (true) { if (sendDataQueue.Count > 0) { SendData sendData = sendDataQueue.Dequeue(); if (sendData != null) { yield return(EditorCoroutine.Start( SendHTTPPost( sendData.url, sendData.logVersion, sendData.GetData()))); } } else { yield return(new WaitForSecondsRealtime(LONG_INTERVAL)); } } }
public virtual void DefaultSetupElements() { var elementName = UIRoot.Q <Foldout>("ElementName"); elementName.text = TemplateName; var ElementsContainer = UIRoot.Q <VisualElement>("ElementsContainer"); UIRoot.Q <Button>("Delete").clickable.clicked += () => lab.DeleteElement(this); UIRoot.Q <Button>("Help").clickable.clicked += () => { EditorCoroutine.Start(OpenHelper()); }; var ToolBox = ElementsContainer.Q("ToolBox"); var KEYWORDS = UIRoot.Q("KeyWords"); KEYWORDS.Clear(); foreach (var kw in keyWords) { if (kw._(KeyWord.Flag.HideInInspector)) { continue; } var kwInput = new KeyWordInput(lab, kw, this); kwInput.RegisterValueChangedCallback((e) => { this.SetValue(kw.key, e.newValue); }); KEYWORDS.Add(kwInput); } var Des = ElementsContainer.Q <TextField>("Description"); Des.value = TemplateDes; Des.SetEnabled(false); //工具箱 ToolBox.Q <Button>("Preview").clickable.clicked += () => SetPreview(); }
private static IEnumerator Save() { int iterations = 60 * 60 * MinutesDelay; // frames count * seconds per minute * minutes count for (float i = 0; i < iterations; i++) { yield return(null); } if (!_isStop) { Debug.Log("Start Auto Save"); if (EditorSceneManager.SaveOpenScenes()) { Debug.Log("All Opened scenes was saved successfull!"); } else { Debug.Log("Saving opened scenes failed"); } EditorCoroutine.Start(Save()); } }
IEnumerator FetchUploadedData() { if (!RemoteConfig.IsInitialized()) { RemoteConfig.Init(); } if (!APIUser.IsLoggedInWithCredentials) { yield break; } ApiCache.ClearResponseCache(); VRCCachedWWW.ClearOld(); if (fetchingAvatars == null) { fetchingAvatars = EditorCoroutine.Start(() => FetchAvatars()); } if (fetchingWorlds == null) { fetchingWorlds = EditorCoroutine.Start(() => FetchWorlds()); } }
static void DownloadImage(string id, string url) { if (string.IsNullOrEmpty(url)) { return; } if (ImageCache.ContainsKey(id) && ImageCache[id] != null) { return; } System.Action <Texture2D> onDone = (texture) => { if (texture != null) { ImageCache[id] = texture; } else if (ImageCache.ContainsKey(id)) { ImageCache.Remove(id); } }; EditorCoroutine.Start(VRCCachedWWW.Get(url, (onDone))); }
private void OnGUITakeButton() { if (_buttonStyle == null) { _buttonStyle = new GUIStyle(GUI.skin.button) { normal = { background = _takeButtonNormal }, active = { background = _takeButtonActive } }; } GUI.enabled = !_hasErrors && !_isMakingScreenshotsNow; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(_takeButtonIcon, _buttonStyle, GUILayout.Width(200f))) { EditorCoroutine.Start(TakeScreenshots()); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
public IndicatorSendManager() { EditorCoroutine.Start(SendLogPolling()); }
public static EditorCoroutine Start(IEnumerator routine) { var coroutine = new EditorCoroutine(routine); coroutine.Start(); return coroutine; }
public void Run() { EditorCoroutine.Start(Upload()); }
public void Play() { Stop(); //Index = -1; playing = EditorCoroutine.Start(playSequence()); }
private static void TakeScreenshotOnHotkey() { EditorCoroutine.Start(TakeScreenshots()); }
public static void Generate(List <GenerationData> dataTypes) { EditorCoroutine.Start(GenerateAsync(dataTypes)); }
void OnGUI() { if (initializer == null) { var assmblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("Unity") || a.FullName.StartsWith("Assembly-CSharp")); assmblies = assmblies.Concat(new[] { typeof(string).Assembly }).OrderBy(a => a.FullName); infos.Clear(); foreach (var item in assmblies) { infos.Add(new AssemblyInfo(item)); } EditorCoroutine.StartMultiple(LoadTypes(), SelectTypes(), FilterTypes()); initializer = new object(); } EditorGUI.BeginDisabledGroup(isBusy); EditorGUILayout.Space(); EditorGUILayout.LabelField("Libraries", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); var w = position.size.x - 200; EditorGUIUtility.labelWidth += w; libraryScroll = EditorGUILayout.BeginScrollView(libraryScroll, GUILayout.Height(200)); foreach (var item in infos) { item.State = EditorGUILayout.Toggle(item.Name, item.State); } EditorGUILayout.EndScrollView(); EditorGUIUtility.labelWidth -= w; if (EditorGUI.EndChangeCheck()) { EditorCoroutine.StartMultiple(SelectTypes(), FilterTypes()); } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField("Filter", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Prefix with t: for a base type"); EditorGUILayout.LabelField("Example: t:Component"); EditorGUILayout.LabelField("Combined example: t:Component Collider"); typeFilter = EditorGUILayout.DelayedTextField(typeFilter); if (EditorGUI.EndChangeCheck()) { EditorCoroutine.Start(FilterTypes()); } EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField("Types", EditorStyles.boldLabel); int pageOffset = page * 100; var rect = EditorGUILayout.GetControlRect(); EditorGUI.BeginDisabledGroup(page == 0); if (GUI.Button(new Rect(rect.x, rect.y, rect.width / 2, rect.height), "<")) { if (page > 0) { page--; typeScroll = Vector2.zero; } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(pageOffset + 100 >= filteredTypes.Count); if (GUI.Button(new Rect(rect.x + (rect.width / 2), rect.y, rect.width / 2, rect.height), ">")) { page++; typeScroll = Vector2.zero; } EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Toggle Page")) { for (int i = pageOffset; i < pageOffset + 100; i++) { if (i < filteredTypes.Count) { var t = filteredTypes[i]; if (!typeStates.ContainsKey(t)) { typeStates.Add(t, false); } typeStates[t] = !typeStates[t]; } else { break; } } } typeScroll = EditorGUILayout.BeginScrollView(typeScroll); EditorGUI.indentLevel++; for (int i = pageOffset; i < pageOffset + 100; i++) { if (i < filteredTypes.Count) { var t = filteredTypes[i]; if (!typeStates.ContainsKey(t)) { typeStates.Add(t, false); } typeStates[t] = EditorGUILayout.ToggleLeft(string.Format("{0} ({1})", t.Name, t.Assembly.GetName().Name), typeStates[t]); } else { break; } } EditorGUI.indentLevel--; EditorGUILayout.EndScrollView(); if (GUILayout.Button("Generate")) { var types = typeStates.Where(t => t.Value) .Select(t => t.Key).Select(t => new WizardData() { Type = t, Name = Utils.GetTypeName(t), Fields = new Dictionary <FieldInfo, bool>().AddRange(GetFields(t).Select(f => new KeyValuePair <FieldInfo, bool>(f, false))), Properties = new Dictionary <PropertyInfo, bool>().AddRange(GetProperties(t).Select(p => new KeyValuePair <PropertyInfo, bool>(p, false))), Methods = new Dictionary <MethodInfo, bool>().AddRange(GetMethods(t).Select(m => new KeyValuePair <MethodInfo, bool>(m, false))), }).ToList(); GeneratorWizard.Init(types); } if (GUILayout.Button("Generate All")) { var types = typeStates.Where(t => t.Value) .Select(t => t.Key).Select(t => new WizardData() { Type = t, Name = Utils.GetTypeName(t), Fields = new Dictionary <FieldInfo, bool>().AddRange(GetFields(t).Select(f => new KeyValuePair <FieldInfo, bool>(f, false))), Properties = new Dictionary <PropertyInfo, bool>().AddRange(GetProperties(t).Select(p => new KeyValuePair <PropertyInfo, bool>(p, false))), Methods = new Dictionary <MethodInfo, bool>().AddRange(GetMethods(t).Select(m => new KeyValuePair <MethodInfo, bool>(m, false))), }).ToList(); foreach (var item in types) { { var keys = item.Fields.Keys; for (int i = keys.Count() - 1; i >= 0; i--) { var key = keys.ElementAt(i); item.Fields[key] = true; } } { var keys = item.Properties.Keys; for (int i = keys.Count() - 1; i >= 0; i--) { var key = keys.ElementAt(i); item.Properties[key] = true; } } { var keys = item.Methods.Keys; for (int i = keys.Count() - 1; i >= 0; i--) { var key = keys.ElementAt(i); item.Methods[key] = true; } } } Generate(types.Select(d => new GenerationData() { Type = d.Type, Fields = d.Fields.Where(f => f.Value).Select(f => f.Key).ToList(), Properties = d.Properties.Where(p => p.Value).Select(f => f.Key).ToList(), Methods = d.Methods.Where(m => m.Value).Select(f => f.Key).ToList(), }).ToList()); } EditorGUI.EndDisabledGroup(); }
private static void FixPrefabs() { EditorCoroutine.Start(_FixPrefabs()); }
/// <summary> /// Translates the given text to <paramref name="targetLang"/>. The function detects automatically the souce language /// </summary> /// <param name="targetLang">The target language</param> /// <param name="sourceText">The text to translate</param> /// <param name="callback">A callback function invoked after the translation</param> public static void Translate(string targetLang, string sourceText, Action <TranslationInfo> callback) { EditorCoroutine.Start(GoogleTranslate.Process("auto", targetLang, sourceText, callback)); }
private static void CaptureScreenshot3() { EditorCoroutine.Start(CaptureScreenshot(3)); }
private void OnGUI() { if (showProgressBar) { EditorUtility.DisplayProgressBar("Installing...", statusMessage, progress / progressTarget); } else { EditorUtility.ClearProgressBar(); } if (PendingPackages.Count > 0 && !EditorApplication.isCompiling && !EditorApplication.isUpdating && !PendingPackageLock) { PendingPackageLock = true; string packageName = PendingPackages[PendingPackages.Count - 1]; PendingPackages.RemoveAt(PendingPackages.Count - 1); AssetDatabase.importPackageCompleted += OnPackageImported; AssetDatabase.importPackageFailed += OnPackageImportFailed; AssetDatabase.ImportPackage(Application.dataPath + "/MLAPI/Lib/" + packageName, false); } GUILayout.BeginArea(new Rect(5, 0, position.width - 5, position.height - (40 + ((string.IsNullOrEmpty(statusMessage) ? 0 : 20) + (canRefetch ? 20 : 0))))); scrollPos = GUILayout.BeginScrollView(scrollPos); tab = GUILayout.Toolbar(tab, new string[] { "GitHub", "Commits" }); if (tab == 0) { if (foldoutStatus != null) { for (int i = 0; i < foldoutStatus.Length; i++) { if (releases[i] == null) { continue; } foldoutStatus[i] = EditorGUILayout.Foldout(foldoutStatus[i], releases[i].tag_name + " - " + releases[i].name); if (foldoutStatus[i]) { EditorGUI.indentLevel++; EditorGUILayout.LabelField("Release notes", EditorStyles.boldLabel); EditorGUILayout.LabelField(releases[i].body, EditorStyles.wordWrappedLabel); EditorGUILayout.Space(); EditorGUILayout.Space(); if (releases[i].prerelease) { GUIStyle style = new GUIStyle(EditorStyles.boldLabel); style.normal.textColor = new Color(1f, 0.5f, 0f); EditorGUILayout.LabelField("Pre-release", style); } else { GUIStyle style = new GUIStyle(EditorStyles.boldLabel); style.normal.textColor = new Color(0f, 1f, 0f); EditorGUILayout.LabelField("Stable-release", style); } if (currentVersion == releases[i].tag_name) { GUIStyle boldStyle = new GUIStyle(EditorStyles.boldLabel); boldStyle.normal.textColor = new Color(0.3f, 1f, 0.3f); EditorGUILayout.LabelField("Installed", boldStyle); } EditorGUILayout.LabelField("Release date: " + DateTime.Parse(DateTime.Parse(releases[i].published_at).ToString()), EditorStyles.miniBoldLabel); if (currentVersion != releases[i].tag_name && GUILayout.Button("Install")) { EditorCoroutine.Start(InstallRelease(i)); } EditorGUI.indentLevel--; } } } } else if (tab == 1) { EditorGUILayout.LabelField("Not yet implemented. The REST API for AppVeyor is proper garbage and is needed to grab the artifact download URLs", EditorStyles.wordWrappedMiniLabel); } GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(5, position.height - (40 + ((string.IsNullOrEmpty(statusMessage) ? 0 : 20) + (canRefetch ? 20 : 0))), position.width - 5, (60 + ((string.IsNullOrEmpty(statusMessage) ? 0 : 20) + (canRefetch ? 20 : 0))))); string lastUpdatedString = lastUpdated == 0 ? "Never" : new DateTime(lastUpdated).ToShortTimeString(); GUILayout.Label("Last checked: " + lastUpdatedString, EditorStyles.centeredGreyMiniLabel); if (canRefetch && GUILayout.Button("Fetch releases")) { EditorCoroutine.Start(GetReleases()); } if (!string.IsNullOrEmpty(statusMessage)) { GUILayout.Label(statusMessage, EditorStyles.centeredGreyMiniLabel); } if (GUILayout.Button("Reset defaults")) { releases = new GithubRelease[0]; foldoutStatus = new bool[0]; if (EditorPrefs.HasKey("MLAPI_version")) { EditorPrefs.DeleteKey("MLAPI_version"); } if (EditorPrefs.HasKey("MLAPI_lastUpdated")) { EditorPrefs.DeleteKey("MLAPI_lastUpdated"); } } GUILayout.EndArea(); if ((releases.Length == 0 && (DateTime.Now - new DateTime(lastUpdated)).TotalSeconds > 600) || (DateTime.Now - new DateTime(lastUpdated)).TotalSeconds > 3600) { EditorCoroutine.Start(GetReleases()); } Repaint(); }
public void Run() { EditorCoroutine.Start(PostNotifyFinishedUpload()); }
public static void Show(string name) { Setup(true); ShowWindow(); EditorCoroutine.Start(WaitForLoad(name)); }