예제 #1
0
    public void HandleBundleDelete_Deletes_VariantFolderAndChildren()
    {
        // Account for existing asset bundles
        int numChildren = ABModelUtil.Root.GetChildList().Count;

        BundleVariantFolderInfo bundleVariantFolderRoot = new BundleVariantFolderInfo("variantFolder", ABModelUtil.Root);

        ABModelUtil.Root.AddChild(bundleVariantFolderRoot);

        BundleVariantDataInfo bundleVariantDataInfo1 = new BundleVariantDataInfo("variant.a", bundleVariantFolderRoot);

        BundleVariantDataInfo bundleVariantDataInfo2 = new BundleVariantDataInfo("variant.b", bundleVariantFolderRoot);

        BundleVariantDataInfo bundleVariantDataInfo3 = new BundleVariantDataInfo("variant.c", bundleVariantFolderRoot);

        bundleVariantFolderRoot.AddChild(bundleVariantDataInfo1);
        bundleVariantFolderRoot.AddChild(bundleVariantDataInfo2);
        bundleVariantFolderRoot.AddChild(bundleVariantDataInfo3);

        FieldInfo numberOfChildrenFieldInfo = typeof(BundleFolderConcreteInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance);
        Dictionary <string, BundleInfo> numberOfConcreteFolderChildren =
            numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>;

        Assert.AreEqual(numChildren + 1, numberOfConcreteFolderChildren.Keys.Count);

        Model.HandleBundleDelete(new BundleInfo[] { bundleVariantFolderRoot });

        numberOfConcreteFolderChildren =
            numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>;

        Assert.AreEqual(numChildren, numberOfConcreteFolderChildren.Keys.Count);
    }
예제 #2
0
        public static void HandleBundleDelete_Deletes_SingleVariantFromVariantFolder()
        {
            // Account for existing asset bundles
            var numChildren = ABModelUtil.Root.GetChildList().Count;
            var numBundles  = AssetDatabase.GetAllAssetBundleNames().Length;

            var bundleVariantFolderRoot = new BundleVariantFolderInfo("variantFolder", ABModelUtil.Root);

            ABModelUtil.Root.AddChild(bundleVariantFolderRoot);

            var bundleVariantDataInfo1 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot);

            bundleVariantDataInfo1.m_Name.variant = "a";

            var bundleVariantDataInfo2 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot);

            bundleVariantDataInfo2.m_Name.variant = "b";

            var bundleVariantDataInfo3 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot);

            bundleVariantDataInfo3.m_Name.variant = "c";

            bundleVariantFolderRoot.AddChild(bundleVariantDataInfo1);
            bundleVariantFolderRoot.AddChild(bundleVariantDataInfo2);
            bundleVariantFolderRoot.AddChild(bundleVariantDataInfo3);

            var numberOfChildrenFieldInfo =
                typeof(BundleFolderConcreteInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance);
            var numberOfConcreteFolderChildren =
                numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>;

            Assert.AreEqual(numChildren + 1, numberOfConcreteFolderChildren.Keys.Count);

            Model.HandleBundleDelete(new BundleInfo[] { bundleVariantDataInfo1 });

            numberOfConcreteFolderChildren =
                numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>;

            Assert.AreEqual(numChildren + 1, numberOfConcreteFolderChildren.Keys.Count);

            var numberOfVariantFolderChildrenFieldInfo =
                typeof(BundleVariantFolderInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance);
            var numberOfVariantFolderChildren =
                numberOfVariantFolderChildrenFieldInfo.GetValue(bundleVariantFolderRoot) as Dictionary <string, BundleInfo>;

            Assert.AreEqual(2, numberOfVariantFolderChildren.Keys.Count);
        }
예제 #3
0
    public void HandleBundleDelete_Deletes_SingleVariantFromVariantFolder()
    {
        BundleVariantFolderInfo bundleVariantFolderRoot = new BundleVariantFolderInfo("variantFolder", ABModelUtil.Root);

        ABModelUtil.Root.AddChild(bundleVariantFolderRoot);

        BundleVariantDataInfo bundleVariantDataInfo1 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot);

        bundleVariantDataInfo1.m_Name.variant = "a";

        BundleVariantDataInfo bundleVariantDataInfo2 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot);

        bundleVariantDataInfo2.m_Name.variant = "b";

        BundleVariantDataInfo bundleVariantDataInfo3 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot);

        bundleVariantDataInfo3.m_Name.variant = "c";

        bundleVariantFolderRoot.AddChild(bundleVariantDataInfo1);
        bundleVariantFolderRoot.AddChild(bundleVariantDataInfo2);
        bundleVariantFolderRoot.AddChild(bundleVariantDataInfo3);

        FieldInfo numberOfChildrenFieldInfo = typeof(BundleFolderConcreteInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance);
        Dictionary <string, BundleInfo> numberOfConcreteFolderChildren =
            numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>;

        Assert.AreEqual(1, numberOfConcreteFolderChildren.Keys.Count);

        Model.HandleBundleDelete(new BundleInfo[] { bundleVariantDataInfo1 });

        numberOfConcreteFolderChildren =
            numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>;

        Assert.AreEqual(1, numberOfConcreteFolderChildren.Keys.Count);

        FieldInfo numberOfVariantFolderChildrenFieldInfo = typeof(BundleVariantFolderInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance);
        Dictionary <string, BundleInfo> numberOfVariantFolderChildren =
            numberOfVariantFolderChildrenFieldInfo.GetValue(bundleVariantFolderRoot) as Dictionary <string, BundleInfo>;

        Assert.AreEqual(2, numberOfVariantFolderChildren.Keys.Count);
    }