Hi all,
I am creating a custom editor, but I'm having a problem and I suspect it may be for ngui, this is the code I am using
using UnityEngine;
using UnityEditor;
using System.Collections;
#if UNITY_EDITOR
public class LetterBox : EditorWindow
{
public string word = "";
public string LenghtString;
[MenuItem("Window/Letter creator")]
public static void Init()
{
LetterBox Window
= (LetterBox
)EditorWindow
.GetWindow(typeof(LetterBox
));
}
private void OnGUI()
{
GUILayout.Label("Welcome to Letter Creator!!!");
EditorGUILayout.Space();
word = EditorGUILayout.TextField("Enter the word: ",word);
if(word.Length==0)
{
EditorGUILayout.HelpBox("First enter a word",MessageType.Warning);
}else
{
EditorGUILayout.LabelField("Lenght = " + word.Length);
}
EditorGUILayout.Space();
if(GUILayout.Button("CREATE BOXES"))
{
if(word.Length!=0)
{
for(int i =0;i<word.Length;i++)
{
Vector3 pos = Vector3.zero;
pos.x = i * 48;
Debug.Log(pos.x);
GameObject box = (GameObject)Resources.Load("hueco");
GameObject go = (GameObject) Instantiate( box ,pos,Quaternion.identity);
go.transform.localPosition = pos;
Debug.Log(go.transform.position);
}
}
}
}
}
#endif
the problem is that all gameobject that are created are created on the axis 0,0,0, but I'm telling you that I would move 48 units in each iteration, the debug display correctly 0, 48, 96 etc, but all are on the axil 0,0,0 . I suspect ngui every time you create something so positioned on the axis 0. How can I solve this problem. Thank you