generated from IvanMurzak/Unity-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathSampleReferences.cs
More file actions
27 lines (23 loc) · 816 Bytes
/
SampleReferences.cs
File metadata and controls
27 lines (23 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Extensions.Unity.ImageLoader;
using UnityEngine;
using UnityEngine.UI;
public class SampleReferences : MonoBehaviour
{
[SerializeField] string imageURL;
[SerializeField] Image image;
void Start()
{
ImageLoader.LoadSpriteRef(imageURL) // load sprite using Reference
.ThenSet(image) // if success set sprite into image, also creates binding to `image`
.Forget();
ImageLoader.LoadSpriteRef(imageURL) // load sprite using Reference
.Then(reference => reference.DisposeOnDestroy(this))
.Then(reference =>
{
var sprite = reference.Value;
// use sprite
})
.Forget();
var count = ImageLoader.GetReferenceCount(imageURL); // get count of references
}
}