# Use CustomType

{% embed url="<https://www.youtube.com/watch?v=Ax5m_dYso2o&ab_channel=HamsterCheeseAllergy>" %}

[ ](https://www.youtube.com/watch?v=Ax5m_dYso2o)

UGS에서는 간단하게 **IType** 인터페이스를 상속받아 사용자 정의 클래스나 구조체를 시트 내에서 사용할 수 있습니다. &#x20;

![](/files/-ML-MSFCBbqLyF6ilapj)

&#x20; 만약 Vector3을 시트에 입력하고 싶다면 어떻게 해야할까요? 아주 단순합니다. 다음과 같이 정의해보세요! (Vector3은 이미 UGS에서 지원하므로 별도로 추가 할 필요가 없긴 합니다.)

```csharp
using UnityEngine; 
namespace Hamster.ZG.Type
{ 
    [Type(typeof(Vector3), new string[] { "vector3", "Vector3", "vec3" })]
    public class Vector3Type : IType
    {
        public object DefaultValue => Vector3.zero;
        /// <summary>
        /// value는 스프레드 시트에 적혀있는 값
        /// </summary> 
        public object Read(string value)
        {
             // value : [1,2,3] 
             var values = ReadUtil.GetBracketValueToArray(value);
             float x = float.Parse(values[0]);
             float y = float.Parse(values[1]);
             float z = float.Parse(values[2]); 
             return new Vector3(x,y,z);
        }

        /// <summary>
        /// value write to google sheet
        /// </summary> 
        public string Write(object value)
        {
            Vector3 v = (Vector3)value;
            return $"[{v.x},{v.y},{v.z}]";
        }
    }
}

```

![](/files/-ML-QtAmuO-0k0UanJEt)

&#x20;작성을하고 파일을 저장하면 UGS 자동으로 타입을 인식합니다. 이제 시트를 다음과 같이 수정해봅시다.

![](/files/-ML-Q5jW_fBMWekx5TUZ)

&#x20;이후, 데이터를 불러와봅시다.

```csharp

using UnityEngine;

public class test : MonoBehaviour
{ 
    void Start()
    {  
        Cube.Data.Load(); 
        foreach(var data in Cube.Data.DataList)
        {
            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.position = data.position;
        }
    } 
}

```

![](/files/-ML-SXe3l9JHIDQeO872)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shlifedev.gitbook.io/unitygooglesheets/and/custom-type.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
