예제 #1
0
        private static string ExecuteGameObjectsEmulation(string nameOrPath, string parent, string root, string upath, Func <List <GameObject>, string> onComplete)
        {
            var autoEvent = new AutoResetEvent(false);

            var response = "";

            MainThreadHelper.QueueOnMainThread(() => {
                try
                {
                    List <GameObject> listOfGOs;
                    if (!string.IsNullOrEmpty(upath))
                    {
                        listOfGOs = FindGameObjectHelper.FindGameObjectsByUPath(upath);
                    }
                    else
                    {
                        listOfGOs = FindGameObjectHelper.GetGameObjects(nameOrPath, root, parent);
                    }

                    response = onComplete(listOfGOs);
                } catch (Exception e) {
                    Log(e);
                    response = e.Message;
                } finally {
                    // set the event to "unlock" the thread
                    autoEvent.Set();
                }
            });

            // wait for the end of the 'action' executed in the main thread
            autoEvent.WaitOne();

            return(response);
        }
예제 #2
0
        public static string ExecuteGameObjectsEmulation(string upath, Func <List <GameObject>, string> onComplete)
        {
            var autoEvent = new AutoResetEvent(false);

            var response = ErrorMessages.MainThreadIsUnavailable; // If response was not changed then MainThreadHelper is not initialized.

            MainThreadQueue.QueueOnMainThread(() =>
            {
                try
                {
                    var listOfGOs = FindGameObjectHelper.FindGameObjectsByUPath(upath);

                    response = onComplete(listOfGOs);
                }
                catch (Exception e)
                {
                    Utils.Logger.Log(e);
                    response = Error + e.ToString();
                }
                finally
                {
                    // set the event to "unlock" the thread
                    autoEvent.Set();
                }
            });

            // wait for the end of the 'action' executed in the main thread or 5 seconds timeout
            autoEvent.WaitOne(5000);

            return(response);
        }