Beispiel #1
0
        public void CheckSceneDupe_SceneDependenciesMatchWithExplicitBundleDependencies()
        {
            Scene      scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
            GameObject go    = AssetDatabase.LoadAssetAtPath <GameObject>(k_CheckDupePrefabA);

            PrefabUtility.InstantiatePrefab(go, scene);
            EditorSceneManager.SaveScene(scene, k_ScenePath);

            var rule = new CheckSceneDupeDependencies();

            EditorBuildSettingsScene editorScene = new EditorBuildSettingsScene(k_ScenePath, true);

            rule.BuiltInResourcesToDependenciesMap(new string[] { editorScene.path });
            rule.IntersectResourcesDepedenciesWithBundleDependencies(new List <GUID>()
            {
                new GUID(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA))
            });

            Assert.IsTrue(rule.m_ResourcesToDependencies.ContainsKey(editorScene.path));
            Assert.AreEqual(1, rule.m_ResourcesToDependencies[editorScene.path].Count);
            Assert.AreEqual(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA), rule.m_ResourcesToDependencies[editorScene.path][0].ToString());

            //Cleanup
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Beispiel #2
0
        public void CheckSceneDupe_AllSceneToBundleDependenciesAreReturned()
        {
            Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);

            PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath <GameObject>(k_PrefabWithMaterialPath), scene);
            EditorSceneManager.SaveScene(scene, k_ScenePath);

            var rule = new CheckSceneDupeDependencies();

            EditorBuildSettingsScene editorScene = new EditorBuildSettingsScene(k_ScenePath, true);

            rule.BuiltInResourcesToDependenciesMap(new string[] { editorScene.path });
            rule.IntersectResourcesDepedenciesWithBundleDependencies(new List <GUID>()
            {
                new GUID(AssetDatabase.AssetPathToGUID(k_CheckDupeMyMaterial)),
                new GUID(AssetDatabase.AssetPathToGUID(k_PrefabWithMaterialPath))
            });

            Assert.IsTrue(rule.m_ResourcesToDependencies.ContainsKey(editorScene.path));
            Assert.AreEqual(2, rule.m_ResourcesToDependencies[editorScene.path].Count);
            Assert.IsTrue(rule.m_ResourcesToDependencies[editorScene.path].Contains(new GUID(AssetDatabase.AssetPathToGUID(k_CheckDupeMyMaterial))));
            Assert.IsTrue(rule.m_ResourcesToDependencies[editorScene.path].Contains(new GUID(AssetDatabase.AssetPathToGUID(k_PrefabWithMaterialPath))));

            //Cleanup
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Beispiel #3
0
        public void CheckSceneDupe_SceneDependenciesDoNotIncludeScripts()
        {
            Scene      scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
            GameObject go    = AssetDatabase.LoadAssetAtPath <GameObject>(k_CheckDupePrefabA);
            GameObject g     = PrefabUtility.InstantiatePrefab(go, scene) as GameObject;

            g.AddComponent <TestBehaviourWithReference>();
            EditorSceneManager.SaveScene(scene, k_ScenePath);

            var rule = new CheckSceneDupeDependencies();

            EditorBuildSettingsScene editorScene = new EditorBuildSettingsScene(k_ScenePath, true);

            rule.BuiltInResourcesToDependenciesMap(new string[] { editorScene.path });

            Assert.IsTrue(rule.m_ResourcesToDependencies.ContainsKey(editorScene.path));
            bool containsAnyScripts = false;

            foreach (GUID guid in rule.m_ResourcesToDependencies[editorScene.path])
            {
                string path = AssetDatabase.GUIDToAssetPath(guid.ToString());
                if (path.EndsWith(".cs") || path.EndsWith(".dll"))
                {
                    containsAnyScripts = true;
                    break;
                }
            }
            Assert.IsFalse(containsAnyScripts, "Scripts were included as a duplciate dependency");

            //Cleanup
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Beispiel #4
0
        public void CheckSceneDupe_SceneDependenciesMatchWithExplicitBundleDependencies()
        {
            Scene      scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
            GameObject go    = AssetDatabase.LoadAssetAtPath <GameObject>(k_CheckDupePrefabA);

            GameObject n     = new GameObject("TestGameObject");
            var        refer = n.AddComponent <TestBehaviourWithReference>();

            refer.Reference = go;
            SceneManager.MoveGameObjectToScene(n, scene);
            EditorSceneManager.SaveScene(scene, k_ScenePath);

            var rule = new CheckSceneDupeDependencies();

            EditorBuildSettingsScene editorScene = new EditorBuildSettingsScene(k_ScenePath, true);

            rule.BuiltInResourcesToDependenciesMap(new string[] { editorScene.path });
            rule.IntersectResourcesDepedenciesWithBundleDependencies(new List <GUID>()
            {
                new GUID(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA))
            });

            Assert.IsTrue(rule.m_ResourcesToDependencies.ContainsKey(editorScene.path));
            Assert.AreEqual(1, rule.m_ResourcesToDependencies[editorScene.path].Count);
            Assert.AreEqual(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA), rule.m_ResourcesToDependencies[editorScene.path][0].ToString());

            //Cleanup
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }