Beispiel #1
0
        public IEnumerator CoroutineWithoutOwner_YieldingIEnumerator()
        {
            EditorCoroutineUtility.StartCoroutineOwnerless(NestedIEnumeratorRoutine());
            yield return(null);

            LogAssert.Expect(LogType.Log, "Start of nesting");

            yield return(null); //yield 1st nested IEnumerator

            LogAssert.Expect(LogType.Log, "PreExecution");

            yield return(null); //yield 2nd nested IEnumerator

            LogAssert.Expect(LogType.Log, "PreExecution");

            yield return(null); //execute 2nd IEnumerator

            LogAssert.Expect(LogType.Log, "PostExecution");

            yield return(null); //execute 1st IEnumerator

            LogAssert.Expect(LogType.Log, "PostExecution");

            //return to routine execution
            LogAssert.Expect(LogType.Log, "End of nesting");
        }
Beispiel #2
0
        public IEnumerator NestedCoroutinesWithoutOwner_WaitForSpecificNumberOfSeconds()
        {
            EditorCoroutineUtility.StartCoroutineOwnerless(ExecuteNestedOwnerlessRoutineswithWaitForSeconds());

            yield return(null); //schedule root routine

            LogAssert.Expect(LogType.Log, "Outer PreExecution");

            yield return(null); //schedule inner routine

            yield return(null); //execute inner coroutine

            double targetTime = EditorApplication.timeSinceStartup + waitTime;

            LogAssert.Expect(LogType.Log, "PreExecution");

            while (targetTime > EditorApplication.timeSinceStartup)
            {
                yield return(null); //wait until target time is reached
            }

            LogAssert.Expect(LogType.Log, "PostExecution");
            yield return(null); //exit inner coroutine

            yield return(null); //run over outer coroutine

            LogAssert.Expect(LogType.Log, "Outer PostExecution");
        }
Beispiel #3
0
        IEnumerator ExecuteNestedOwnerlessRoutineswithWaitForSeconds()
        {
            Debug.Log("Outer PreExecution");
            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(ExecuteRoutineWithWaitForSeconds()));

            Debug.Log("Outer PostExecution");
        }
        static void HandleLog(string logString, string stackTrace, LogType type)
        {
            switch (type)
            {
            case LogType.Error:
                // Debug.Log("Error Message");
                break;

            default:
                return;
            }
            output = logString;
            stack  = stackTrace;
            lm     = new LogMessage
            {
                st  = stack,
                msg = output,
            };
            logMessages.log.Add(lm);
            if (logCount == 0)
            {
                logMessages.ts = DateTime.Now.ToString();
                coroutine      = EditorCoroutineUtility.StartCoroutineOwnerless(EditorAttempt(0.5f));
            }
            else
            {
                EditorCoroutineUtility.StopCoroutine(coroutine);
                coroutine = EditorCoroutineUtility.StartCoroutineOwnerless(EditorAttempt(0.5f));
            }
            // sw.Close();
        }
Beispiel #5
0
        public static IEnumerator ReplaceWithDefault(PrefabDataHolder[] prefabs)
        {
            IsBusy = true;
            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(ReplaceWithDefaultCoroutine(prefabs)));

            IsBusy = false;
        }
        protected override void OnGuiCloseSafe(EditorButtonAttribute attribute)
        {
            var targetObjects = InspectorUtility.CurrentTargetObjects;

            if (targetObjects == null || targetObjects.Length == 0)
            {
                //NOTE: something went really wrong, internal bug or OnGuiBeginSafe was called out of the Toolbox scope
                return;
            }

            var disable = !IsClickable(attribute.ActivityType);

            using (new EditorGUI.DisabledScope(disable))
            {
                var label = string.IsNullOrEmpty(attribute.ExtraLabel)
                            ? attribute.MethodName
                            : attribute.ExtraLabel;
                var tooltip = attribute.Tooltip;
                var content = new GUIContent(label, tooltip);

                if (GUILayout.Button(content, Style.buttonStyle))
                {
                    var targetType = targetObjects[0].GetType();
                    var method     = targetType.GetMethod(attribute.MethodName,
                                                          BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                    //validate method name (check if method exists)
                    if (method == null)
                    {
                        ToolboxEditorLog.AttributeUsageWarning(attribute, attribute.MethodName + " method not found.");
                        return;
                    }

                    //validate parameters count and log warning
                    var parameters = method.GetParameters();
                    if (parameters.Length > 0)
                    {
                        ToolboxEditorLog.AttributeUsageWarning(attribute, attribute.MethodName + " method has to be parameterless.");
                        return;
                    }

                    //invoke method for all selected components
                    var isCoroutine = IsCoroutine(targetType, method);
                    for (var i = 0; i < targetObjects.Length; i++)
                    {
                        var target = targetObjects[i];
                        if (target == null)
                        {
                            continue;
                        }

                        var result = method.Invoke(target, null);
                        //additionaly run Coroutine if possible
                        if (isCoroutine)
                        {
                            EditorCoroutineUtility.StartCoroutineOwnerless((IEnumerator)result);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        static public void StartProfiling(string filename)
        {
#if MEMPROFILER_PROFILE
#if MEMPROFILER_PROFILE_LOGFILE
            UnityEngine.Profiling.Profiler.logFile         = filename;
            UnityEngine.Profiling.Profiler.enableBinaryLog = true;
#endif
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.Audio, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.CPU, true);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.GlobalIllumination, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.GPU, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.Memory, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.NetworkMessages, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.NetworkOperations, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.Physics, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.Physics2D, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.Rendering, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.UI, true);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.UIDetails, false);
            UnityEngine.Profiling.Profiler.SetAreaEnabled(UnityEngine.Profiling.ProfilerArea.Video, false);

            foreach (var r in AllMarkerRecorders())
            {
                r.Recorder.enabled = true;
            }
            UnityEngine.Profiling.Profiler.enabled = true;
            s_ProfilingStep = k_ProfilingStepMax;

            EditorCoroutineUtility.StartCoroutineOwnerless(StepProfiling());
#endif
        }
    // After opening, set up transform, coroutine, etc. that can only run on main thread
    // Should be called by both OpenAsync and Open
    void PostOpenMainThreadSetup(string urlPath)
    {
#if NET_4_6
        Debug.Assert(Thread.CurrentThread == mainThread);
#endif
        HVCollider.center      = localSpaceBounds.center;
        HVCollider.size        = localSpaceBounds.size;
        meshFilter.mesh.bounds = localSpaceBounds;

        Update3DAudio();
        UpdateUnityBuffers(true);

        if (UnityBufferCoroutine != null)
        {
#if UNITY_EDITOR && USE_EDITOR_COROUTINE
            EditorCoroutineUtility.StopCoroutine(UnityBufferCoroutine);
#else
            StopCoroutine(UnityBufferCoroutine);
#endif
        }
#if UNITY_EDITOR && USE_EDITOR_COROUTINE
        UnityBufferCoroutine = EditorCoroutineUtility.StartCoroutineOwnerless(FillUnityBuffers());
#else
        UnityBufferCoroutine = StartCoroutine(FillUnityBuffers());
#endif

        HandleOnOpen(urlPath);
    }
Beispiel #9
0
 public static void InitializeWorker()
 {
     // The client here spawned could also be launched from the command line.
     PythonRunner.SpawnClient(CLIENT_PATH,
                              wantLogging: true);
     EditorCoroutineUtility.StartCoroutineOwnerless(WaitForWorkerAndInitialize());
 }
Beispiel #10
0
 public static void Dispose()
 {
     if (!Coroutines.IsInitialising && IsInitialised)
     {
         EditorCoroutineUtility.StartCoroutineOwnerless(Coroutines.Dispose());
     }
 }
Beispiel #11
0
        public static IEnumerator Initialise(string bundlesRoot)
        {
            IsInitialising = true;
            ProgressManager.RemoveProgressBars("Asset Bundles");

            int progressID = Progress.Start("Load Asset Bundles", null, Progress.Options.Sticky);
            int bundleID   = Progress.Start("Bundles", null, Progress.Options.Sticky, progressID);
            int materialID = Progress.Start("Materials", null, Progress.Options.Sticky, progressID);
            int prefabID   = Progress.Start("Replace Prefabs", null, Progress.Options.Sticky, progressID);

            Progress.Report(bundleID, 0f);
            Progress.Report(materialID, 0f);
            Progress.Report(prefabID, 0f);

            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(LoadBundles(bundlesRoot, (progressID, bundleID, materialID))));

            if (!IsInitialising)
            {
                Progress.Finish(bundleID, Progress.Status.Failed);
                Progress.Finish(materialID, Progress.Status.Failed);
                Progress.Finish(prefabID, Progress.Status.Failed);
                yield break;
            }
            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(SetBundleReferences((progressID, bundleID))));

            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(SetMaterials(materialID)));

            IsInitialised = true; IsInitialising = false;
            SetVolumeGizmos();
            Callbacks.OnBundlesLoaded();
            PrefabManager.ReplaceWithLoaded(PrefabManager.CurrentMapPrefabs, prefabID);
        }
Beispiel #12
0
 static void HandleLog(string logString, string stackTrace, string type = "")
 {
     if (logString != prevMsg)
     {
         output = logString;
         stack  = stackTrace;
         lm     = new LogMessage {
             st   = stack,
             src  = "unity",
             msg  = output,
             type = type
         };
         if (repeated > 0)
         {
             lm.msg = lm.msg + repeated.ToString();
         }
         logMessages.log.Add(lm);
         prevMsg = lm.msg;
         if (logCount == 0)
         {
             logMessages.ts = DateTime.UtcNow.ToString();
             coroutine      = EditorCoroutineUtility.StartCoroutineOwnerless(EditorAttempt(0.5f));
         }
         else
         {
             EditorCoroutineUtility.StopCoroutine(coroutine);
             coroutine = EditorCoroutineUtility.StartCoroutineOwnerless(EditorAttempt(0.5f));
         }
     }
     else
     {
         repeated++;
     }
     // sw.Close();
 }
Beispiel #13
0
        /// <summary>
        /// シーケンスを実行する
        /// </summary>
        public EditorCoroutine Play()
        {
            var coroutine = EditorCoroutineUtility.StartCoroutineOwnerless(GetEnumerator());

            _coroutines.Add(coroutine);
            return(coroutine);
        }
Beispiel #14
0
        /// <summary>
        /// シーケンスのIEnumeratorを取得する
        /// </summary>
        private IEnumerator GetEnumerator()
        {
            // InsertされたIEnumeratorの実行
            int counter = _insertedEnumerators.Count;

            foreach (InsertedEnumerator insertedEnumerator in _insertedEnumerators)
            {
                var coroutine = EditorCoroutineUtility.StartCoroutineOwnerless(insertedEnumerator.GetEnumerator(() =>
                {
                    counter--;
                }));
                _coroutines.Add(coroutine);
            }
            // InsertされたIEnumeratorが全て実行されるのを待つ
            while (counter > 0)
            {
                yield return(null);
            }
            // AppendされたIEnumeratorの実行
            foreach (IEnumerator appendedEnumerator in _appendedEnumerators)
            {
                yield return(appendedEnumerator);
            }
            // 終了時の処理
            if (_onCompleted != null)
            {
                _onCompleted();
            }
        }
//----------------------------------------------------------------------------------------------------------------------

        #region CheckPluginUpdates Button callback
        private void OnCheckPluginUpdatesButtonClicked()
        {
            m_checkPluginUpdatesButton.SetEnabled(false);

            //Disable installing plugin while we are checking for updates
            foreach (Button installPluginButton in m_installPluginButtons)
            {
                installPluginButton.SetEnabled(false);
            }

            m_updateFooterStatusFinished = false;
            EditorCoroutineUtility.StartCoroutineOwnerless(UpdateFooterStatusLabel("Checking", FinalizeCheckPluginUpdates));

            PackageRequestJobManager.CreateSearchRequest("com.unity.meshsync.dcc-plugins", /*offline=*/ false, (packageInfo) => {
                //just in case
                if (packageInfo.Result.Length <= 0)
                {
                    Debug.LogError("[MeshSync] Failed to check DCC Plugin updates");
                    m_updateFooterStatusFinished = true;
                    return;
                }

                //Update status labels
                UpdateLatestCompatibleDCCPlugin(packageInfo.Result[0].versions);
                foreach (KeyValuePair <string, Label> kv in m_dccStatusLabels)
                {
                    UpdateDCCPluginStatusLabel(kv.Value);
                }

                m_updateFooterStatusFinished = true;
            }, (req) => {
                m_updateFooterStatusFinished = true;
            });
        }
    /// <summary>
    /// Fit
    /// </summary>
    void OnWizardCreate()
    {
        Undo.RegisterCompleteObjectUndo(this.SkinnedMeshRenderer, "Automatic Collider Fitting");
        Debug.Log("Automatic Collider Fitting.", this.SkinnedMeshRenderer);

        co = EditorCoroutineUtility.StartCoroutineOwnerless(this.ProcessBones());
    }
Beispiel #17
0
        public static IEnumerator SpawnPrefabs(PrefabData[] prefabs)
        {
            IsBusy = true;
            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(SpawnPrefabsCoroutine(prefabs)));

            IsBusy = false;
        }
Beispiel #18
0
        protected override void OnGuiBeginSafe(ImageAreaAttribute attribute)
        {
            var url = attribute.Url;

            if (!textures.TryGetValue(url, out var texture))
            {
                textures[url] = texture = new DownloadedTexture(true);
                EditorCoroutineUtility.StartCoroutineOwnerless(SendGetImageRequest(url, (b, t) =>
                {
                    textures[url] = new DownloadedTexture(false, t);
                    if (b)
                    {
                        InspectorUtility.RepaintInspectors();
                    }
                    else
                    {
                        ToolboxEditorLog.AttributeUsageWarning(attribute, "Cannot retrive image from the provided URL - " + url);
                    }
                }));
            }

            if (texture.Texture2D != null)
            {
                EditorGUILayout.LabelField(new GUIContent(texture.Texture2D), Style.imageStyle, GUILayout.Height(attribute.Height));
            }
        }
Beispiel #19
0
 /// <summary>Replaces the selected prefabs with the default prefabs.</summary>
 public static void ReplaceWithDefault(PrefabDataHolder[] prefabs)
 {
     if (!Coroutines.IsBusy)
     {
         EditorCoroutineUtility.StartCoroutineOwnerless(Coroutines.ReplaceWithDefault(prefabs));
     }
 }
Beispiel #20
0
 /// <summary>Replaces the selected prefabs with ones from the Rust bundles.</summary>
 public static void ReplaceWithLoaded(PrefabDataHolder[] prefabs)
 {
     if (AssetManager.IsInitialised && !Coroutines.IsBusy)
     {
         EditorCoroutineUtility.StartCoroutineOwnerless(Coroutines.ReplaceWithLoaded(prefabs));
     }
 }
Beispiel #21
0
 /// <summary>Spawns prefabs for map load.</summary>
 public static void SpawnPrefabs(PrefabData[] prefabs)
 {
     if (!Coroutines.IsBusy)
     {
         EditorCoroutineUtility.StartCoroutineOwnerless(Coroutines.SpawnPrefabs(prefabs));
     }
 }
Beispiel #22
0
        public static IEnumerator CreateMap(int size, int ground = 4, int biome = 1, float landHeight = 503f)
        {
            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(Load(EmptyMap(size, landHeight), "New Map")));

            PaintLayer(LandLayers.Ground, ground);
            PaintLayer(LandLayers.Biome, biome);
        }
Beispiel #23
0
        void StartTwoFA(string mFAKey)
        {
            MFAKey      = mFAKey;
            SecretCode  = String.Empty;
            currentView = LootLockerView.TwoFactorAuth;

            TwoFATockenTimoutCo = EditorCoroutineUtility.StartCoroutineOwnerless(TwoFATockenTimout());
        }
Beispiel #24
0
        public static IEnumerator ChangeLayer(LandLayers layer, int topology = 0)
        {
            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(SaveLayer()));

            yield return(EditorCoroutineUtility.StartCoroutineOwnerless(SetLayer(layer, topology)));

            LayerSet = true;
        }
Beispiel #25
0
        static LoaderEnabledCheck()
        {
            s_ARKitSettings = ARKitSettings.GetOrCreateSettings();
            ARKitBuildProcessor.s_LoaderEnabled = s_ARKitSettings.faceTracking;

            UpdateARKitDefines();
            EditorCoroutineUtility.StartCoroutineOwnerless(UpdateARKitDefinesCoroutine());
        }
 public void LoadGitPackageJson()
 {
     EditorCoroutineUtility.StartCoroutineOwnerless(PackageManager.GetPackageFromGit(this, answer =>
     {
         gitPackage = JsonUtility.FromJson <PackageModel>(answer);
         OnGitPackagesJsonLoaded?.Invoke();
     }));
 }
Beispiel #27
0
        void CreateTutorialMenuCards(VisualTreeAsset vistree, string cardElementName, string linkCardElementName, VisualElement cardContainer)
        {
            var cards = Cards.OrderBy(card => card.OrderInView).ToArray();

            // "Start Here" marker, will be replaced by tooltip when we have such.
            // showStartHereMarker = !tutorials.Any(t => t.section.tutorialCompleted);
            cardContainer.style.alignItems = Align.Center;

            for (int index = 0; index < cards.Length; ++index)
            {
                var card = cards[index];

                // If it's a tutorial, use tutorial card - otherwise link card
                VisualElement cardElement = vistree.CloneTree().Q("TutorialsContainer").Q(card.IsTutorial ? cardElementName : linkCardElementName);
                cardElement.Q <Label>("TutorialName").text        = Localization.Tr(card.Heading.Untranslated); // TODO use Heading(.Translated) when localization fixed
                cardElement.Q <Label>("TutorialDescription").text = Localization.Tr(card.Text.Untranslated);    // TODO use Heading(.Translated) when localization fixed
                if (card.IsTutorial)
                {
                    cardElement.RegisterCallback((MouseUpEvent evt) =>
                    {
                        card.StartTutorial();
                        //ShowCurrentTutorialContent();
                    });
                }
                if (!string.IsNullOrEmpty(card.Url))
                {
                    AnalyticsHelper.SendExternalReferenceImpressionEvent(card.Url, card.Heading.Untranslated, card.LinkText, card.TutorialId);

                    cardElement.RegisterCallback((MouseUpEvent evt) =>
                    {
                        card.OpenUrl();
                    });
                }

                EditorApplication.delayCall += () =>
                {
                    EditorApplication.delayCall += () =>
                    {
                        // HACK: needs two delaycalls or GenesisHelper gives 404
                        FetchTutorialStates();
                    };
                };

                cardElement.Q <Label>("CompletionStatus").text = cards[index].TutorialCompleted ? Localization.Tr("COMPLETED") : "";
                SetElementVisible(cardElement.Q("TutorialCheckmark"), cards[index].TutorialCompleted);

                EditorCoroutineUtility.StartCoroutineOwnerless(EnforceCheckmark(cards[index], cardElement));

                if (card.Image != null)
                {
                    cardElement.Q("TutorialImage").style.backgroundImage = Background.FromTexture2D(card.Image);
                }
                cardElement.tooltip = card.IsTutorial
                    ? Localization.Tr("Tutorial: ") + card.Text.Untranslated // TODO Use Text(.Translated) when localization fixed
                    : card.Url;
                cardContainer.Add(cardElement);
            }
        }
Beispiel #28
0
            public IEnumerator SetLayer(LandLayers layer, int topology = 0)
            {
                yield return(EditorCoroutineUtility.StartCoroutineOwnerless(SetLayerCoroutine(layer, topology)));

                LayerSet = true;
                foreach (var item in Land.terrainData.alphamapTextures)
                {
                    Undo.ClearUndo(item);
                }
            }
Beispiel #29
0
    public static void DestroyEditorSafe(Object victim)
    {
#if UNITY_EDITOR
        //delay destruction outside the current call context (for example for OnValidate where we cant destroy)
        EditorCoroutineUtility.StartCoroutineOwnerless(DestroyRoutine(victim));
#else
        //this should never be called in the game, but if we do, this should work.
        Object.Destroy(victim);
#endif
    }
Beispiel #30
0
 /// <summary>Loads the Rust bundles into memory.</summary>
 /// <param name="bundlesRoot">The file path to the Rust bundles file.</param>
 public static void Initialise(string bundlesRoot)
 {
     if (!Coroutines.IsInitialising && !IsInitialised)
     {
         EditorCoroutineUtility.StartCoroutineOwnerless(Coroutines.Initialise(bundlesRoot));
     }
     if (IsInitialised)
     {
         Debug.Log("Bundles already loaded.");
     }
 }