Author Topic: Custom editor and NGUI problem  (Read 3268 times)

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Custom editor and NGUI problem
« on: December 03, 2014, 07:57:16 AM »
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

  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4.  
  5. #if UNITY_EDITOR
  6. public class LetterBox : EditorWindow
  7. {
  8.  
  9.         public string word = "";
  10.         public string LenghtString;
  11.  
  12.         [MenuItem("Window/Letter creator")]
  13.         public static void Init()
  14.         {
  15.  
  16.                 LetterBox Window = (LetterBox)EditorWindow.GetWindow(typeof(LetterBox));
  17.  
  18. }
  19.  
  20.  
  21.         private void OnGUI()
  22.         {
  23.  
  24.                 GUILayout.Label("Welcome to Letter Creator!!!");
  25.                 EditorGUILayout.Space();
  26.                 word = EditorGUILayout.TextField("Enter the word: ",word);
  27.                 if(word.Length==0)
  28.                 {
  29.                         EditorGUILayout.HelpBox("First enter a word",MessageType.Warning);
  30.  
  31.                 }else
  32.                 {
  33.                         EditorGUILayout.LabelField("Lenght = " + word.Length);
  34.                 }
  35.  
  36.                 EditorGUILayout.Space();
  37.  
  38.                 if(GUILayout.Button("CREATE BOXES"))
  39.                 {
  40.                         if(word.Length!=0)
  41.                         {
  42.                         for(int i =0;i<word.Length;i++)
  43.                         {
  44.                                 Vector3 pos = Vector3.zero;
  45.                                 pos.x = i * 48;
  46.                                 Debug.Log(pos.x);
  47.                                 GameObject box = (GameObject)Resources.Load("hueco");
  48.                                 GameObject go = (GameObject) Instantiate( box ,pos,Quaternion.identity);
  49.                                 go.transform.localPosition = pos;
  50.                                 Debug.Log(go.transform.position);
  51.                         }
  52.  
  53.                         }
  54.  
  55.                 }
  56.  
  57.  
  58.  
  59.         }
  60.  
  61.  
  62.  
  63.  
  64. }
  65. #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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Custom editor and NGUI problem
« Reply #1 on: December 04, 2014, 03:44:40 AM »
Do you not see this sticky post at the top of this forum? http://www.tasharen.com/forum/index.php?topic=11208.0