public void GenericShouldLoadAssetFromNameAndType()
        {
            go = PrefabUtility.SaveAsPrefabAsset(Object.Instantiate(new GameObject(TestAssetName)), $"assets/{TestAssetName}.prefab");

            GameObject loadedAsset = SingleAssetLoader.Load <GameObject>(TestAssetName);

            Assert.IsNotNull(loadedAsset);
            Assert.AreEqual(TestAssetName, loadedAsset.name);
        }
        public void ShouldLoadAssetFromNameAndType()
        {
            Type type = typeof(GameObject);

            go = PrefabUtility.SaveAsPrefabAsset(Object.Instantiate(new GameObject(TestAssetName)), $"assets/{TestAssetName}.prefab");

            Object loadedAsset = SingleAssetLoader.Load(TestAssetName, type);

            Assert.AreEqual(type, loadedAsset.GetType());
            Assert.AreEqual(TestAssetName, loadedAsset.name);
        }
Ejemplo n.º 3
0
    public void LoadAsyn <T>(string name, LoadCallBack <T> callBack) where T : UnityEngine.Object
    {
        string abName = GetAbName(name);

        GetAssetBundleAsyn(abName,
                           assetBundle =>
        {
            SingleAssetLoader <T> assetLoader = new SingleAssetLoader <T>(assetBundle, name, callBack);
            assetLoader.Load();
        });
    }
Ejemplo n.º 4
0
        public void OnEnable()
        {
            if (m_Root is null)
            {
                m_Root = new VisualElement();
            }

            m_Root.Clear();
            m_Root.Bind(serializedObject);
            SingleAssetLoader.Load <VisualTreeAsset>("ListTest").CloneTree(m_Root);
            m_Root.Add(new ListElement.ListElement(serializedObject.FindProperty(nameof(TestListBehaviour2.MyList))));
            m_Root.Add(new ListElement.ListElement(
                           serializedObject.FindProperty(nameof(TestListBehaviour2.MyObjectList))));
        }
Ejemplo n.º 5
0
        public static void LoadAndAddStyleSheet(VisualElement element, string stylesheetName, string templateName)
        {
            if (stylesheetName == templateName)
            {
                return;
            }

            try
            {
                element.styleSheets.Add(
                    SingleAssetLoader.Load <StyleSheet>(stylesheetName));
            }
            catch (Exception e)
            {
                Debug.LogWarningFormat("Could not load custom style sheet:\n{0}", e.Message);
            }
        }
        public void ShouldThrowIfAssetDoesNotExist()
        {
            Type type = typeof(GameObject);

            bool errorThrown = false;

            try
            {
                SingleAssetLoader.Load(TestAssetName, type);
            }
            catch
            {
                errorThrown = true;
            }

            Assert.IsTrue(errorThrown);
        }
Ejemplo n.º 7
0
        public void ShouldBeSetFromFromUxml()
        {
            VisualElement test = new VisualElement();

            SingleAssetLoader.Load <VisualTreeAsset>(TestHelpers.DefaultTestTemplateWthOptionsSetName).CloneTree(test);

            ListElement listElement = test.Q <ListElement>();

            listElement.BindProperty(TestHelpers.GetProperty());
            //yield return null;
            var results = CompareSetsAreEqual(listElement.Options, testSet);

            if (results.Count > 0)
            {
                string errorLine = string.Join("\n",
                                               results.Select(x =>
                                                              $"{x.Name} was set to '{x.GetValue(GetListOptions(listElement.Options))}', should be '{x.GetValue(testSet)}'"));
                Assert.Fail($"Following options were not set correctly from UXML:\n{errorLine}");
            }
        }
Ejemplo n.º 8
0
 public RowGenerator(string itemTemplateName)
 {
     template = SingleAssetLoader.Load <VisualTreeAsset>(itemTemplateName);
 }
Ejemplo n.º 9
0
 public void OneTime()
 {
     Options  = new ListOptions();
     template = SingleAssetLoader.Load <VisualTreeAsset>(Options.TemplateName);
 }