private static void StartGlobalCustomMessageQueue() { StopGlobalCustomMessageQueue(); _globalCustomMessageQueueRoutine = GlobalCustomMessageQueueRoutine(); CoroutineRunner.RunCoroutine(_globalCustomMessageQueueRoutine); }
/// <summary> /// Used to initialize the routine asynchronously /// </summary> /// <param name="languageId">Language ID</param> /// <returns>IEnumerator</returns> private IEnumerator InitializeRoutine(string languageId) { // Copies all tess data to persistent directory yield return CoroutineRunner.RunCoroutine(InitializeTessdataRoutine()); string[] languageSplit = languageId.Split('+'); // Check whether we have stored the correct tesseract language data for(int i = 0; i < languageSplit.Length; i++) { if(!m_AvailableDataSet.Contains(languageSplit[i])) { Debug.LogWarning(string.Format("Tesseract language id is not available. Please check your settings for the correct data import. [{0}]", languageSplit[i])); } } if(m_Handle != IntPtr.Zero) { // Perform initialization from the native library if(TesseractOCRBridge.Initialize(m_Handle, GetTessdataPersistentPath(), languageId) == 0) { // Copies the configuration file to persistent directory and sets the config file to use yield return CoroutineRunner.RunCoroutine(InitializeConfigFileRoutine(true)); Debug.Log("Initialize TesseractOCR Success!"); } else { Debug.Log("Initialize TesseractOCR Failed!"); } } }
public static void ExecuteTriggerList(List <GameEventTrigger> triggers, Action action) { if (triggers != null && triggers.Count > 0) { CoroutineRunner.RunCoroutine(ExecuteTriggerListRoutine(triggers, action)); } }
public void Cleanup() { var coroutine = CoroutineRunner.RunCoroutine(HLODCreator.Destroy(m_hlod)); while (coroutine.MoveNext()) { } }
/// <summary> /// Used to initialize Tesseract OCR library /// </summary> /// <param name="languageId">Language ID</param> public void Initialize(string languageId) { if(m_Handle == IntPtr.Zero) { m_Handle = TesseractOCRBridge.CreateTesseractHandle(); } CoroutineRunner.RunCoroutine(InitializeRoutine(languageId)); }
/// <summary> /// Begins the request for a download from the server. /// </summary> /// <returns> Returns the data downloaded from the server if the request was successful; otherwise, notfies of an error. </returns> public Coroutine Download() { if (Status == MoBackRequest.RequestState.NOT_FINISHED) { Debug.LogError("You are already downloading this file!"); return(null); } return(CoroutineRunner.RunCoroutine(DoDownload())); }
public void Cleanup() { var coroutine = CoroutineRunner.RunCoroutine(HLODCreator.Destroy(hlod)); while (coroutine.MoveNext()) { //Wait until coroutine is finished } File.Delete(mHlodArtifactName); Assert.False(File.Exists(mHlodArtifactName)); }
public void Setup() { GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(m_prefabName); m_hlodGameObject = (GameObject)PrefabUtility.InstantiatePrefab(prefab); PrefabUtility.UnpackPrefabInstance(m_hlodGameObject, PrefabUnpackMode.OutermostRoot, InteractionMode.AutomatedAction); m_hlod = m_hlodGameObject.GetComponentInChildren <HLOD>(); var coroutine = CoroutineRunner.RunCoroutine(HLODCreator.Create(m_hlod)); while (coroutine.MoveNext()) { //Wait until coroutine is finished } }
public void Setup() { Scene scene = EditorSceneManager.OpenScene("Assets/TestAssets/EditModeTestScene.unity"); GameObject[] gameObjects = scene.GetRootGameObjects(); mHlodGameObject = gameObjects[0].transform.Find("HLOD").gameObject; hlod = mHlodGameObject.GetComponent <HLOD>() as HLOD; var coroutine = CoroutineRunner.RunCoroutine(HLODCreator.Create(hlod)); while (coroutine.MoveNext()) { //Wait until coroutine is finished } }
public void ChangeState(T state) { if (EqualityComparer <T> .Default.Equals(state, m_currentState)) { return; } Func <IEnumerator> entering = GetValue(m_enteringFunctions, state); Func <IEnumerator> exiting = GetValue(m_exitingFunctions, m_currentState); Action entered = GetValue(m_enteredFunctions, state); Action exited = GetValue(m_exitedFunctions, m_currentState); m_lastRun = CoroutineRunner.RunCoroutine(Changing(m_lastRun, entering, exiting, entered, exited)); m_currentState = state; }
/// <summary> /// Initializes tess data and its directory /// </summary> /// <returns>IEnumerator</returns> private IEnumerator InitializeTessdataRoutine() { string persistentDataPath = GetTessdataPersistentPath(); if(Directory.Exists(persistentDataPath)) { string[] tessdataFiles = Directory.GetFiles(persistentDataPath, "*" + TESS_DATA_EXT, SearchOption.TopDirectoryOnly); // Fetch available stored tesseract language data from persistent datapath for(int i = 0; i < tessdataFiles.Length; i++) { m_AvailableDataSet.Add(Path.GetFileNameWithoutExtension(tessdataFiles[i])); } } HashSet<string> selectedTessdataSet = new HashSet<string>(); TesseractOCRSettings.TessDataInfo[] tessdataInfoList = TesseractOCRSettings.Instance.GetSelectedTessdata(); // Get all required tesseract language data for(int i = 0; i < tessdataInfoList.Length; i++) { string filename = Path.GetFileNameWithoutExtension(tessdataInfoList[i].name); yield return CoroutineRunner.RunCoroutine(LoadTesseractDataRoutine(filename, true)); m_AvailableDataSet.Add(filename); selectedTessdataSet.Add(filename); } // Exclude unused tesseract language data HashSet<string> removedTessdataSet = new HashSet<string>(m_AvailableDataSet); removedTessdataSet.ExceptWith(selectedTessdataSet); // Remove unused tesseract language data to reduce application size foreach(string removedTessdata in removedTessdataSet) { m_AvailableDataSet.Remove(removedTessdata); string fullFilePath = Path.Combine(persistentDataPath, removedTessdata + TESS_DATA_EXT); File.Delete(fullFilePath); } }
/// <summary> /// Coroutine to run a request. /// </summary> /// <returns> The current status of the request. </returns> public Coroutine Run() { if (State == RequestState.NOT_FINISHED) { if (MoBackAppSettings.loggingLevel >= MoBackAppSettings.LoggingLevel.WARNINGS) { Debug.LogWarning("Trying to run a MoBackRequest when it's already running."); } return(currentRun); } State = RequestState.NOT_FINISHED; #if UNITY_ANDROID if (!MoBackRequestManager.SSLValidator.initialized) { MoBackRequestManager.SSLValidator.init(); } #endif new Thread(Execute).Start(); currentRun = CoroutineRunner.RunCoroutine(PollForAndProcessResponse()); return(currentRun); }
public static void ExecuteCustomMessageQueue(List <NetworkMessage> messages, float delay) { IEnumerator newQueue = ExecuteCustomMessageQueueRoutine(messages, delay); CoroutineRunner.RunCoroutine(newQueue); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUI.BeginChangeCheck(); TerrainHLOD hlod = target as TerrainHLOD; if (hlod == null) { EditorGUILayout.LabelField("TerrainHLOD is null."); return; } isShowCommon = EditorGUILayout.BeginFoldoutHeaderGroup(isShowCommon, "Common"); if (isShowCommon == true) { EditorGUILayout.PropertyField(m_TerrainDataProperty, Styles.SourceText); EditorGUILayout.PropertyField(m_DestoryTerrainProperty, Styles.DestoryTerrainText); EditorGUILayout.PropertyField(m_ChunkSizeProperty); m_ChunkSizeProperty.floatValue = HLODUtils.GetChunkSizePropertyValue(m_ChunkSizeProperty.floatValue); var bounds = hlod.GetBounds(); int depth = m_splitter.CalculateTreeDepth(bounds, m_ChunkSizeProperty.floatValue); EditorGUILayout.LabelField($"The HLOD tree will be created with {depth} levels."); if (depth > 5) { EditorGUILayout.LabelField($"Node Level Count greater than 5 may cause a frozen Editor.", Styles.RedTextColor); EditorGUILayout.LabelField($"Use a value less than 5.", Styles.RedTextColor); } EditorGUILayout.PropertyField(m_BorderVertexCountProperty); m_LODSlider.Draw(); } EditorGUILayout.EndFoldoutHeaderGroup(); isShowSimplifier = EditorGUILayout.BeginFoldoutHeaderGroup(isShowSimplifier, "Simplifier"); if (isShowSimplifier == true) { if (m_SimplifierTypes.Length > 0) { int simplifierIndex = Math.Max(Array.IndexOf(m_SimplifierTypes, hlod.SimplifierType), 0); simplifierIndex = EditorGUILayout.Popup("Simplifier", simplifierIndex, m_SimplifierNames); hlod.SimplifierType = m_SimplifierTypes[simplifierIndex]; var info = m_SimplifierTypes[simplifierIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod.SimplifierOptions }); } } } else { EditorGUILayout.LabelField("Can not find Simplifiers."); } } EditorGUILayout.EndFoldoutHeaderGroup(); isShowMaterial = EditorGUILayout.BeginFoldoutHeaderGroup(isShowMaterial, "Material"); if (isShowMaterial == true) { Material mat = null; string matGUID = hlod.MaterialGUID; if (string.IsNullOrEmpty(matGUID) == false) { string path = AssetDatabase.GUIDToAssetPath(matGUID); mat = AssetDatabase.LoadAssetAtPath <Material>(path); } mat = EditorGUILayout.ObjectField("Material", mat, typeof(Material), false) as Material; if (mat != null) { string path = AssetDatabase.GetAssetPath(mat); hlod.MaterialGUID = AssetDatabase.AssetPathToGUID(path); } matGUID = hlod.MaterialLowGUID; if (string.IsNullOrEmpty(matGUID) == false) { string path = AssetDatabase.GUIDToAssetPath(matGUID); mat = AssetDatabase.LoadAssetAtPath <Material>(path); } mat = EditorGUILayout.ObjectField("MaterialLow", mat, typeof(Material), false) as Material; if (mat != null) { string path = AssetDatabase.GetAssetPath(mat); hlod.MaterialLowGUID = AssetDatabase.AssetPathToGUID(path); } hlod.TextureSize = EditorGUILayout.IntPopup("Size", hlod.TextureSize, Styles.TextureSizeStrings, Styles.TextureSizes); //Output Property name //EditorGUILayout. if (mat == null) { mat = new Material(Shader.Find("Standard")); } string[] outputTexturePropertyNames = mat.GetTexturePropertyNames(); int index = 0; isShowTexturePropertices = EditorGUILayout.Foldout(isShowTexturePropertices, "Texture propertices"); if (isShowTexturePropertices == true) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Toggle(true, GUILayout.Width(20)); index = Array.IndexOf(outputTexturePropertyNames, hlod.AlbedoPropertyName); index = EditorGUILayout.Popup("Albedo", index, outputTexturePropertyNames); index = (index < 0) ? 0 : index; hlod.AlbedoPropertyName = outputTexturePropertyNames[index]; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); hlod.UseNormal = EditorGUILayout.Toggle(hlod.UseNormal, GUILayout.Width(20)); index = Array.IndexOf(outputTexturePropertyNames, hlod.NormalPropertyName); index = EditorGUILayout.Popup("Normal", index, outputTexturePropertyNames); index = (index < 0) ? 0 : index; hlod.NormalPropertyName = outputTexturePropertyNames[index]; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); hlod.UseMask = EditorGUILayout.Toggle(hlod.UseMask, GUILayout.Width(20)); index = Array.IndexOf(outputTexturePropertyNames, hlod.MaskPropertyName); index = EditorGUILayout.Popup("Mask", index, outputTexturePropertyNames); index = (index < 0) ? 0 : index; hlod.MaskPropertyName = outputTexturePropertyNames[index]; EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndFoldoutHeaderGroup(); isShowStreaming = EditorGUILayout.BeginFoldoutHeaderGroup(isShowStreaming, "Streaming"); if (isShowStreaming == true) { if (m_StreamingTypes.Length > 0) { int streamingIndex = Math.Max(Array.IndexOf(m_StreamingTypes, hlod.StreamingType), 0); streamingIndex = EditorGUILayout.Popup("Streaming", streamingIndex, m_StreamingNames); hlod.StreamingType = m_StreamingTypes[streamingIndex]; var info = m_StreamingTypes[streamingIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod.StreamingOptions }); } } } else { EditorGUILayout.LabelField("Can not find StreamingSetters."); } } EditorGUILayout.EndFoldoutHeaderGroup(); GUIContent generateButton = Styles.GenerateButtonEnable; GUIContent destroyButton = Styles.DestroyButtonNotExists; if (hlod.GetComponent <HLODControllerBase>() != null) { generateButton = Styles.GenerateButtonExists; destroyButton = Styles.DestroyButtonEnable; } EditorGUILayout.Space(); GUI.enabled = generateButton == Styles.GenerateButtonEnable; if (GUILayout.Button(generateButton)) { CoroutineRunner.RunCoroutine(TerrainHLODCreator.Create(hlod)); } GUI.enabled = destroyButton == Styles.DestroyButtonEnable; if (GUILayout.Button(destroyButton)) { CoroutineRunner.RunCoroutine(TerrainHLODCreator.Destroy(hlod)); } GUI.enabled = true; serializedObject.ApplyModifiedProperties(); }
public static void InitializeNetwork() { AddEventListeners(); initializeResponseEvent.Invoke(); CoroutineRunner.RunCoroutine(DebugLogRoutine()); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUI.BeginChangeCheck(); HLOD hlod = target as HLOD; if (hlod == null) { EditorGUILayout.LabelField("HLOD is null."); return; } isShowCommon = EditorGUILayout.BeginFoldoutHeaderGroup(isShowCommon, "Common"); if (isShowCommon == true) { EditorGUILayout.PropertyField(m_MinSizeProperty); m_LODSlider.Draw(); EditorGUILayout.PropertyField(m_ThresholdSizeProperty); } EditorGUILayout.EndFoldoutHeaderGroup(); isShowSimplifier = EditorGUILayout.BeginFoldoutHeaderGroup(isShowSimplifier, "Simplifier"); if (isShowSimplifier == true) { if (m_SimplifierTypes.Length > 0) { int simplifierIndex = Math.Max(Array.IndexOf(m_SimplifierTypes, hlod.SimplifierType), 0); simplifierIndex = EditorGUILayout.Popup("Simplifier", simplifierIndex, m_SimplifierNames); hlod.SimplifierType = m_SimplifierTypes[simplifierIndex]; var info = m_SimplifierTypes[simplifierIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod }); } } } else { EditorGUILayout.LabelField("Can not find Simplifiers."); } } EditorGUILayout.EndFoldoutHeaderGroup(); isShowBatcher = EditorGUILayout.BeginFoldoutHeaderGroup(isShowBatcher, "Batcher"); if (isShowBatcher == true) { if (m_BatcherTypes.Length > 0) { int batcherIndex = Math.Max(Array.IndexOf(m_BatcherTypes, hlod.BatcherType), 0); batcherIndex = EditorGUILayout.Popup("Batcher", batcherIndex, m_BatcherNames); hlod.BatcherType = m_BatcherTypes[batcherIndex]; var info = m_BatcherTypes[batcherIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod }); } } } else { EditorGUILayout.LabelField("Can not find Batchers."); } } EditorGUILayout.EndFoldoutHeaderGroup(); isShowStreaming = EditorGUILayout.BeginFoldoutHeaderGroup(isShowStreaming, "Streaming"); if (isShowStreaming == true) { if (m_StreamingTypes.Length > 0) { int streamingIndex = Math.Max(Array.IndexOf(m_StreamingTypes, hlod.StreamingType), 0); streamingIndex = EditorGUILayout.Popup("Streaming", streamingIndex, m_StreamingNames); hlod.StreamingType = m_StreamingTypes[streamingIndex]; var info = m_StreamingTypes[streamingIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod }); } } } else { EditorGUILayout.LabelField("Can not find StreamingSetters."); } } EditorGUILayout.EndFoldoutHeaderGroup(); GUIContent generateButton = Styles.GenerateButtonEnable; GUIContent destroyButton = Styles.DestroyButtonNotExists; if (PrefabStageUtility.GetCurrentPrefabStage() == null || PrefabStageUtility.GetCurrentPrefabStage().prefabContentsRoot == null) { //generate is only allow in prefab mode. GUI.enabled = false; generateButton = Styles.GenerateButtonDisable; destroyButton = Styles.DestroyButtonDisable; } else if (hlod.GetComponent <ControllerBase>() != null) { generateButton = Styles.GenerateButtonExists; destroyButton = Styles.DestroyButtonEnable; } EditorGUILayout.Space(); GUI.enabled = generateButton == Styles.GenerateButtonEnable; if (GUILayout.Button(generateButton)) { CoroutineRunner.RunCoroutine(HLODCreator.Create(hlod)); } GUI.enabled = destroyButton == Styles.DestroyButtonEnable; if (GUILayout.Button(destroyButton)) { CoroutineRunner.RunCoroutine(HLODCreator.Destroy(hlod)); } GUI.enabled = true; serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { if (PrefabStageUtility.GetCurrentPrefabStage() != null) { EditorSceneManager.MarkSceneDirty(PrefabStageUtility.GetCurrentPrefabStage().scene); } } }
void _Shoot() { CoroutineRunner.RunCoroutine(this.onAtk()); }
public static void StartCoroutine(IEnumerator coroutine) => CoroutineRunner.RunCoroutine(coroutine);
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUI.BeginChangeCheck(); HLOD hlod = target as HLOD; if (hlod == null) { EditorGUILayout.LabelField("HLOD is null."); return; } isShowCommon = EditorGUILayout.BeginFoldoutHeaderGroup(isShowCommon, "Common"); if (isShowCommon == true) { EditorGUILayout.PropertyField(m_ChunkSizeProperty); m_ChunkSizeProperty.floatValue = HLODUtils.GetChunkSizePropertyValue(m_ChunkSizeProperty.floatValue); var bounds = hlod.GetBounds(); int depth = m_splitter.CalculateTreeDepth(bounds, m_ChunkSizeProperty.floatValue); EditorGUILayout.LabelField($"The HLOD tree will be created with {depth} levels."); if (depth > 5) { EditorGUILayout.LabelField($"Node Level Count greater than 5 may cause a frozen Editor.", Styles.RedTextColor); EditorGUILayout.LabelField($"I recommend keeping the level under 5.", Styles.RedTextColor); } m_LODSlider.Draw(); EditorGUILayout.PropertyField(m_MinObjectSizeProperty); } EditorGUILayout.EndFoldoutHeaderGroup(); isShowSimplifier = EditorGUILayout.BeginFoldoutHeaderGroup(isShowSimplifier, "Simplifier"); if (isShowSimplifier == true) { if (m_SimplifierTypes.Length > 0) { int simplifierIndex = Math.Max(Array.IndexOf(m_SimplifierTypes, hlod.SimplifierType), 0); simplifierIndex = EditorGUILayout.Popup("Simplifier", simplifierIndex, m_SimplifierNames); hlod.SimplifierType = m_SimplifierTypes[simplifierIndex]; var info = m_SimplifierTypes[simplifierIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod.SimplifierOptions }); } } } else { EditorGUILayout.LabelField("Cannot find Simplifiers."); } } EditorGUILayout.EndFoldoutHeaderGroup(); isShowBatcher = EditorGUILayout.BeginFoldoutHeaderGroup(isShowBatcher, "Batcher"); if (isShowBatcher == true) { if (m_BatcherTypes.Length > 0) { int batcherIndex = Math.Max(Array.IndexOf(m_BatcherTypes, hlod.BatcherType), 0); batcherIndex = EditorGUILayout.Popup("Batcher", batcherIndex, m_BatcherNames); hlod.BatcherType = m_BatcherTypes[batcherIndex]; var info = m_BatcherTypes[batcherIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod, isFirstOnGUI }); } } } else { EditorGUILayout.LabelField("Cannot find Batchers."); } } EditorGUILayout.EndFoldoutHeaderGroup(); isShowStreaming = EditorGUILayout.BeginFoldoutHeaderGroup(isShowStreaming, "Streaming"); if (isShowStreaming == true) { if (m_StreamingTypes.Length > 0) { int streamingIndex = Math.Max(Array.IndexOf(m_StreamingTypes, hlod.StreamingType), 0); streamingIndex = EditorGUILayout.Popup("Streaming", streamingIndex, m_StreamingNames); hlod.StreamingType = m_StreamingTypes[streamingIndex]; var info = m_StreamingTypes[streamingIndex].GetMethod("OnGUI"); if (info != null) { if (info.IsStatic == true) { info.Invoke(null, new object[] { hlod.StreamingOptions }); } } } else { EditorGUILayout.LabelField("Cannot find StreamingSetters."); } } EditorGUILayout.EndFoldoutHeaderGroup(); GUIContent generateButton = Styles.GenerateButtonEnable; GUIContent destroyButton = Styles.DestroyButtonNotExists; if (hlod.GetComponent <HLODControllerBase>() != null) { generateButton = Styles.GenerateButtonExists; destroyButton = Styles.DestroyButtonEnable; } EditorGUILayout.Space(); GUI.enabled = generateButton == Styles.GenerateButtonEnable; if (GUILayout.Button(generateButton)) { CoroutineRunner.RunCoroutine(HLODCreator.Create(hlod)); } GUI.enabled = destroyButton == Styles.DestroyButtonEnable; if (GUILayout.Button(destroyButton)) { CoroutineRunner.RunCoroutine(HLODCreator.Destroy(hlod)); } GUI.enabled = true; serializedObject.ApplyModifiedProperties(); isFirstOnGUI = false; }