예제 #1
0
        void BuildConstructorExtensions()
        {
            uiConstructor     = new UiImgConstructor();
            spriteConstructor = new SpriteConstructor();

            Type targetType = typeof(IPsdConstructor);
            Type sprType    = typeof(SpriteConstructor);
            Type uiType     = typeof(UiImgConstructor);

//		    Type textType = typeof (TextConstructor);
            Type[] constructorTypes = AppDomain.CurrentDomain.GetAssemblies()
                                      .SelectMany(s => s.GetTypes())
                                      .Where(p => targetType.IsAssignableFrom(p) && p.IsClass &&
                                             !(p == sprType || p == uiType))
                                      .ToArray();

            List <IPsdConstructor> constructors   = new List <IPsdConstructor>();
            List <GUIContent>      constructNames = new List <GUIContent>();

            foreach (Type t in constructorTypes)
            {
                IPsdConstructor constructor = Activator.CreateInstance(t) as IPsdConstructor;
                if (constructor == null)
                {
                    continue;
                }

                constructors.Add(constructor);
                constructNames.Add(new GUIContent(constructor.MenuName));
            }

            constructorExtensions = constructors.ToArray();
            constructorNames      = constructNames.ToArray();
        }
예제 #2
0
        public GameObject CreateGameObject(string name, GameObject parent)
        {
            GameObject go = SpriteConstructor.GOFactory(name, parent);

#if !NGUI
            // Unity UI objects need Rect Transforms,
            // add the component after creating the base object
            RectTransform rectTrans = go.AddComponent <RectTransform>();
            rectTrans.sizeDelta = Vector2.zero;
#endif
            return(go);
        }
예제 #3
0
 public GameObject CreateGameObject(string name, GameObject parent)
 {
     return(SpriteConstructor.GOFactory(name, parent));
 }