コード例 #1
0
        public void CanRestrictLabel()
        {
            m_AssetReferenceDrawer = new AssetReferenceDrawer();
            TestObjectWithRestrictedRef obj = ScriptableObject.CreateInstance <TestObjectWithRestrictedRef>();
            var so       = new SerializedObject(obj);
            var property = so.FindProperty("Reference");

            m_AssetReferenceDrawer.GatherFilters(property);
            Assert.AreEqual(m_AssetReferenceDrawer.Restrictions.Count, 1);
            List <AssetReferenceUIRestrictionSurrogate> restrictions = m_AssetReferenceDrawer.Restrictions;

            Assert.True(restrictions.First().ToString().Contains("HD"));
        }
コード例 #2
0
        public void AssetReferenceDrawer_HandleDragAndDrop_CanRecognizeNonAddressableInAddressableFolder()
        {
            // ScriptableObject property and Drawer setup
            m_AssetReferenceDrawer = new AssetReferenceDrawer();
            m_AssetReferenceDrawer.m_AssetRefObject = new AssetReference();
            TestObjectWithRestrictedRef obj = ScriptableObject.CreateInstance <TestObjectWithRestrictedRef>();
            var so           = new SerializedObject(obj);
            var propertyName = "Reference";
            var property     = so.FindProperty(propertyName);

            // Group setup
            string groupName = "TestGroup";

            Settings.CreateGroup(groupName, false, false, false, null);

            // Asset setup
            var newEntryPath = ConfigFolder + "/test" + "/test.prefab";
            var folderGuid   = CreateTestPrefabAddressable(newEntryPath);
            var newAssetGuid = AssetDatabase.AssetPathToGUID(newEntryPath);

            Settings.CreateOrMoveEntry(folderGuid, Settings.groups[2]);
            Directory.CreateDirectory("Assets/AddressableAssetsData");
            AddressableAssetSettingsDefaultObject.Settings = Settings;

            // Test
            m_AssetReferenceDrawer.DragAndDropNotFromAddressableGroupWindow(newEntryPath, newAssetGuid, property, Settings);
            var newentry = Settings.FindAssetEntry(newAssetGuid);

            Assert.IsNull(newentry);
            Assert.AreEqual(m_AssetReferenceDrawer.m_AssetRefObject.AssetGUID, newAssetGuid);

            // Cleanup
            Settings.RemoveAssetEntry(AssetDatabase.AssetPathToGUID(newEntryPath));
            Settings.RemoveAssetEntry(folderGuid);
            Settings.RemoveGroup(Settings.groups[2]);
            if (Directory.Exists(ConfigFolder + "/test"))
            {
                AssetDatabase.DeleteAsset(ConfigFolder + "/test");
            }
            m_AssetReferenceDrawer = null;
        }