본문 바로가기
프론트엔드

Unity ColorUtility

by 느바 2022. 10. 11.
반응형

Unity ColorUtility

1. TryParseHtmlString

 

Unity - Scripting API: ColorUtility.TryParseHtmlString

Strings that begin with '#' will be parsed as hexadecimal in the following way: #RGB (becomes RRGGBB) #RRGGBB #RGBA (becomes RRGGBBAA) #RRGGBBAA When not specified alpha will default to FF. Strings that do not begin with '#' will be parsed as literal color

docs.unity3d.com

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Man : MonoBehaviour
{
    Color color;
    
    void Start()
    {
        ColorUtility.TryParseHtmlString(objColor, out color);
        GetComponent<MeshRenderer>().material.color = new Color(color.r, color.g, color.b, 1.0f);
    }
}

 

2.

 

3.

반응형