본문 바로가기
개발/C#

유니티 C# 리소스 로드 Resource.Load 함수 간단 사용법

by SPNK 2022. 8. 17.
반응형
  • 코드 작성
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ResourceLoad : MonoBehaviour
{

    void Start() 
    {
        GameObject obj = Resources.Load("GameObject") as GameObject;

        Sprite sprite = Resources.Load("GameObject") as Sprite;

        AudioClip audioClip = Resources.Load("GameObject") as AudioClip;

        TextAsset textAsset = Resources.Load("GameObject") as TextAsset;

        Texture2D texture2D = Resources.Load("GameObject") as Texture2D;

        Animator animator = Resources.Load("GameObject") as Animator;      
    }
}

 

 


참고할만한 글

 

유니티 C# 파일 저장 경로 System Path 간단 사용법

using System.IO; using UnityEngine; public static class SystemPath { public static string GetPath(string fileName) //파일 위치 불러오기 { string path = GetPath(); return Path.Combine(GetPath(), fileName); } public static string GetPath() //플랫

parksh3641.tistory.com

 

Unity - Scripting API: Resources.Load

This method returns the asset at path if it can be found, otherwise it returns null. Note that the path is case insensitive and must not contain a file extension. All asset names and paths in Unity use forward slashes, so using backslashes in the path will

docs.unity3d.com

 

반응형

댓글