Exemplo n.º 1
0
        private void HandleBeforeOpenProjectEvent(object sender, BeforeOpenProjectEventArgs e)
        {
            //
            // A project is being loaded. Store the current time and the order.
            //
            var entry = new LoadEntry(m_LoadingTimes.Count + 1,
                                      DateTimeOffset.Now.ToUnixTimeMilliseconds());

            m_LoadingTimes.Add(e.Project, entry);
        }
    private static void Execute()
    {
        LoadEntry current = _loadFlow[_loadStep];

        current.hasLoaded = current.function.Invoke();

        if (current.hasLoaded)
        {
            _localStopwatch.Stop();

            UnityEngine.Debug.Log(current.loadText + " took " + _localStopwatch.Elapsed);
        }
    }
    private static void Next()
    {
        _loadStep++;

        if (_loadStep == _loadFlow.Count)
        {
            Finish();
            return;
        }

        LoadEntry current = _loadFlow[_loadStep];

        _loadingScreen.SetProgress((float)_loadStep / (float)_loadFlow.Count);
        _loadingScreen.SetText(current.loadText);

        _localStopwatch = new Stopwatch();
        _localStopwatch.Start();
    }
    private static void Poll()
    {
        if (HasLoaded)
        {
            return;
        }

        LoadEntry current = _loadFlow[_loadStep];

        if (current.hasLoaded)
        {
            Next();
        }
        else
        {
            Execute();
        }
    }
Exemplo n.º 5
0
        /// <summary>
        /// Load a file
        ///
        /// Called by an incoming http connection =>
        /// THREADSAFETY: Called from web server thread => do not call Unity code from this thread!
        /// </summary>
        /// <param name="data">Data.</param>
        public string Load(Dictionary <string, string> data)
        {
            string filename = data ["file"];

            LoadEntry loadEntry = new LoadEntry();

            loadEntry.filename   = "Assets/" + filename;
            loadEntry.waitHandle = new AutoResetEvent(false);

            lock (lockThis) {
                specificAssetsToLoad.Add(loadEntry);
            }

            // Load is done in another thread -> wait for it
            loadEntry.waitHandle.WaitOne(10000);

            return(loadEntry.content);
        }