Beispiel #1
0
    public void HandleBundleReparent_MovesBundleVariant_ToCorrectParent()
    {
        BundleFolderConcreteInfo concreteFolder    = Model.CreateEmptyBundleFolder() as BundleFolderConcreteInfo;
        BundleFolderConcreteInfo subConcreteFolder = Model.CreateEmptyBundleFolder(concreteFolder) as BundleFolderConcreteInfo;
        BundleFolderConcreteInfo startParent       = Model.CreateEmptyBundleFolder(subConcreteFolder) as BundleFolderConcreteInfo;

        BundleVariantDataInfo bundleVariantDataInfo = new BundleVariantDataInfo("v1", startParent);

        Model.HandleBundleReparent(new BundleInfo[] { bundleVariantDataInfo }, concreteFolder);
        Assert.AreEqual(concreteFolder, bundleVariantDataInfo.parent);
    }
Beispiel #2
0
    public void HandleBundleReparent_MovesBundleFolderVariant_ToCorrectParent()
    {
        BundleFolderConcreteInfo concreteFolder      = Model.CreateEmptyBundleFolder() as BundleFolderConcreteInfo;
        BundleFolderConcreteInfo startParent         = Model.CreateEmptyBundleFolder() as BundleFolderConcreteInfo;
        BundleVariantDataInfo    bundleVariantFolder = Model.CreateEmptyVariant(new BundleVariantFolderInfo("v1", startParent)) as BundleVariantDataInfo;

        Model.HandleBundleReparent(new BundleInfo[] { bundleVariantFolder }, concreteFolder);

        Assert.AreNotEqual(String.Empty, bundleVariantFolder.parent.m_Name.bundleName);
        Assert.AreEqual(concreteFolder, bundleVariantFolder.parent);
    }
Beispiel #3
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);
        }
Beispiel #4
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);
    }
        internal void ValidateVariants()
        {
            m_validated = true;
            bool childMismatch = false;

            if (m_Children.Count > 1)
            {
                BundleVariantDataInfo goldChild = null;
                foreach (var c in m_Children)
                {
                    var child = c.Value as BundleVariantDataInfo;
                    child.SetMessageFlag(MessageSystem.MessageFlag.VariantBundleMismatch, false);
                    if (goldChild == null)
                    {
                        goldChild = child;
                        continue;
                    }
                    childMismatch |= goldChild.FindContentMismatch(child);
                }
            }
            m_BundleMessages.SetFlag(MessageSystem.MessageFlag.VariantBundleMismatch, childMismatch);
        }