类似于我之前问的一个问题,我现在正在寻找学习如何在脚本中获取我的图像TestImage
的参考。
到目前为止,我已经尝试过:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class imageGrab : MonoBehaviour
{
[Space] public RawImage testImage;
Texture2D profileTexture;
// Start is called before the first frame update
void Start()
{
profileTexture = new Texture2D(2, 2);
}
void Awake()
{
PlayPortalProfileClient.Instance.GetMyProfilePicture((error, data) =>
{
if (error != null)
{
ErrorLogging("Error requesting my profile picture.", error);
}
else
{
Debug.Log("Got my profile picture successfully.");
profileTexture.LoadImage(data);
testImage.texture = profileTexture;
}
});
}
// Update is called once per frame
void Update()
{
}
}
但是遇到此错误,Assets/imageGrab.cs(8,24): error CS0246: The type or namespace name 'RawImage' could not be found (are you missing a using directive or an assembly reference?)
我可以做些什么来正确获得参考?有像引用文本元素一样简单的事情吗?谢谢!
将其放在顶部:
using UnityEngine.UI