Beispiel #1
0
 private void AddComponentNamesInScene()
 {
     foreach (var gObject in FindAllObjects.InScene <GameObject>())
     {
         RenameGameObject(gObject);
     }
 }
Beispiel #2
0
        private static void CheckLevelEnterPlayModeForLoadingMainScene()
        {
            if (!ProjectEditorConfig.Instance.AutoTestLevelScenes)
            {
                return;
            }

            // No game exists
            var game = FindAllObjects.InScene <GameBase>().FirstOrDefault();

            if (game)
            {
                return;
            }

            // Found level helper
            var sceneRef = FindAllObjects.InScene <LevelSceneRefBase>();

            if (sceneRef.Length <= 0)
            {
                return;
            }

            ManagedLog.Log($"Loading main scene to test {SceneManager.GetActiveScene().name}");

            var testingScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(SceneManager.GetActiveScene().path);

            GameWindow.TestLevel = AssetDatabase.LoadAssetAtPath <SceneAsset>(SceneManager.GetActiveScene().path);

            _asyncOperation = EditorSceneManager.LoadSceneAsyncInPlayMode(GameWindow.MainSceneAssetPath,
                                                                          new LoadSceneParameters(LoadSceneMode.Single));

            _asyncOperation.completed += OnloadComplete;

            void OnloadComplete(AsyncOperation obj)
            {
                game = FindAllObjects.InScene <GameBase>().FirstOrDefault();
                _asyncOperation.completed -= OnloadComplete;
                Assert.IsNotNull(game);

#if USING_SHAPES
                WorldLog.OnScreen($"Testing {testingScene.name}");
#endif
                new Operation(delay: 1f, action: () =>
                {
                    game.StartGame();
                }).Start();
            }
        }
Beispiel #3
0
        private void ReplaceTmpTextString(string searchFor, string replaceWith)
        {
            var textMeshProUGuis = FindAllObjects.InScene <TMP_Text>();

            var changed = new List <TMP_Text>();

            foreach (var textMeshProUgui in textMeshProUGuis.Where(ugui => ugui.text.Contains(searchFor)))
            {
                textMeshProUgui.text = textMeshProUgui.text.Replace(searchFor, replaceWith);
                changed.Add(textMeshProUgui);
                EditorUtility.SetDirty(textMeshProUgui);
            }

            Debug.Log($"Replaced {changed.Count} names!");
            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            Selection.objects = changed.Select(ugui => ugui.gameObject).ToArray();
        }
Beispiel #4
0
        private void ReplaceImageColors(Color searchFor, Color replaceWith)
        {
            var images = FindAllObjects.InScene <Image>();

            Undo.RecordObjects(images, "Replace Colors");

            var changed = new List <Image>();

            foreach (var image in images.Where(image => image.color == searchFor))
            {
                image.color = replaceWith;
                Debug.Log($"Replacing {image.name} sprite");
                changed.Add(image);
            }

            Debug.Log($"Replaced {changed.Count} sprites!");
        }
Beispiel #5
0
        private void ReplaceNameString(string searchFor, string replaceWith)
        {
            var gameObjects = FindAllObjects.InScene <GameObject>();

            Undo.RecordObjects(gameObjects, "ReplaceNameString");

            var changed = new List <GameObject>();

            foreach (var image in gameObjects.Where(go => go.name.Contains(searchFor)))
            {
                image.name = image.name.Replace(searchFor, replaceWith);
                changed.Add(image);
            }

            Debug.Log($"Replaced {changed.Count} names!");
            Selection.objects = changed.ToArray();
        }
Beispiel #6
0
        private void ReplaceTmpTextColors(Color searchFor, Color replaceWith)
        {
            var texts = FindAllObjects.InScene <TextMeshProUGUI>();

            Undo.RecordObjects(texts, "Replace TMP Text Colors");

            var changed = new List <TextMeshProUGUI>();

            foreach (var text in texts.Where(text => text.color == searchFor))
            {
                text.color = replaceWith;
                Debug.Log($"Replacing {text.name} text");
                changed.Add(text);
            }

            Debug.Log($"Replaced {changed.Count} texts!");
        }
Beispiel #7
0
        private void ReplaceImageSprite(Sprite searchFor, Sprite replaceWith)
        {
            var images = FindAllObjects.InScene <Image>();

            Undo.RecordObjects(images, "Replace Sprites");

            var changedImages = new List <Image>();

            foreach (var image in images.Where(spriteRenderer => spriteRenderer.sprite == searchFor))
            {
                image.sprite = replaceWith;
                Debug.Log($"Replacing {image.name} sprite");
                changedImages.Add(image);
            }

            Debug.Log($"Replaced {changedImages.Count} sprites!");
            Selection.objects = changedImages.ToArray();
        }