Advertisement
Berenger

[Berenger] ClassWindow.cs

Dec 5th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections.Generic;
  4.  
  5. public class ClassWindow : EditorWindow
  6. {  
  7.     private static ClassWindow window;
  8.     public List< ClassA > list;
  9.    
  10.     [MenuItem ("My Window/Class")]
  11.     static void Init ()
  12.     {
  13.         window = EditorWindow.GetWindow (typeof (ClassWindow)) as ClassWindow;
  14.         Debug.Log("Init");
  15.     }
  16.    
  17.     private void OnGUI()
  18.     {
  19.         if( list == null )
  20.             list = new List<ClassA>();
  21.        
  22.         if( GUI.Button( new Rect( 10, 10, 100, 100 ), "Add Class A" ) )
  23.             list.Add( new ClassA() );
  24.        
  25.         if( GUI.Button( new Rect( 110, 10, 100, 100 ), "Add Class B" ) )
  26.             list.Add( new ClassB() );
  27.        
  28.         // Once you compile again, this is going to display only 'AAAAAAAAA'
  29.         GUILayout.BeginArea( new Rect( 10, 110, 200, 200 ) );
  30.             GUILayout.Space(20);
  31.             GUILayout.Label( "Childcount : " + list.Count );
  32.             GUILayout.Space(20);
  33.             foreach( ClassA a in list )
  34.                 a.Draw();
  35.         GUILayout.EndArea();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement