1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Unity で Resources.load()を使って Texture 2D を呼び出したい。

Posted at

Sprite で呼び出す場合と異なり、Texture 2D の設定に細かい修正が必要だったので覚書。

Importしたpng を inspector view で修正

以下の画像のように修正
image.png

Texture Type : From Sprite to “Default”

Advanced -> Read/Write Enabled “Check”

Script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EasyMobile;
using UnityEngine.UI;

public class ImportT2dManager : MonoBehaviour
{
    Texture2D texture2d; 
	Sprite    sprite;
   
    private void Awake()
    {
        texture2d = ScreenShotManager.screenShotInfo.texture = Resources.Load("Texture2dImage", typeof(Texture2D)) as Texture2D;
        sprite = Resources.Load<Sprite>("SpriteImage");
    }
}

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?