-1
나는 작은 스크립트를 작성합니다. FontCustomEditor.setRects() (자산/에디터/FontCustomEditor.cs에서 : 56) :IndexOutOfRangeException 자동 유니티 사용자 정의 글꼴 파일에 RECT PARAMS을 소개하지만 난이 오류를 충족하기위한 유니티 C#을
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(Font))]
public class FontCustomEditor : Editor {
public int countX = 10;
public int countY = 10;
public string[] horOrient = new string[] { "Left to Right", "Right to Left" };
public int horOrientIndex = 0;
public string[] verOrient = new string[] { "Down to Up", "Up to Down" };
public int verOrientIndex = 0;
public string characters = "ABCDEFJKLMNOPQRSTUVWXY";
public Font font;
private bool showParams;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
showParams = EditorGUILayout.Foldout(showParams, "Automatic Set Rect Positions");
if (showParams) {
countX = EditorGUILayout.IntField("Count x", countX);
countY = EditorGUILayout.IntField("Count y", countY);
horOrientIndex = EditorGUILayout.Popup(horOrientIndex, horOrient);
verOrientIndex = EditorGUILayout.Popup(verOrientIndex, verOrient);
characters = EditorGUILayout.TextField("Characters", characters);
if (GUILayout.Button("Apply", GUILayout.Width(100)))
{
setRects();
}
}
}
public void setRects() {
font = (Font)target;
float rectX = 1f/countX, rectY = 1f/countY;
int i, j, counter;
CharacterInfo[] chr = new CharacterInfo[characters.Length];
for (i = 0; i < countX; i++)
{
for (j = 0; j < countY; j++)
{
counter = (i * countX + j);
if (counter <= characters.Length) {
float uvx, uvy;
uvx = Mathf.Abs((j - ((countX - 1) * horOrientIndex)) * rectX);
uvy = Mathf.Abs((i - ((countY - 1) * verOrientIndex)) * rectY);
chr[counter + 0] = new CharacterInfo(){ //Line 56 chr.Length = 22; counter = 0;
index = characters[counter] + 0,
uvBottomLeft = new Vector2(uvx, uvy),
uvBottomRight = new Vector2(uvx, uvy + rectY),
uvTopLeft = new Vector2(uvx + rectX, uvy),
uvTopRight = new Vector2(uvx + rectX, uvy + rectY)
};
}
}
}
font.characterInfo = chr;
}
}
이 제발 도와
이 내 코드입니다. 나는 내가 뭘 잘못했는지 이해할 수 없다.
카운터 유형에서 문제를 찾으려고합니다. – user3520223