Unityコンパイラ拡張-リファレンス

2921 ワード

プリフォームの作成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class ImageMergeWindow :EditorWindow  {

    [MenuItem("Window/S_ImageMerge")]
    static void S_ImageMerge()
    {
        ImageMergeWindow window = EditorWindow.GetWindow ();
        window.autoRepaintOnSceneChange = true;
        window.Show ();
    //    EditorApplication.hierarchyWindowChanged += hierarchyWindowChanged;
    //    EditorApplication.projectWindowChanged += projectWindowChanged;

    }
//    static void  projectWindowChanged()
//    {
//        Debug.Log (" update  projectWindowChanged 26 ");
//    }
//
//
//    static void  hierarchyWindowChanged()
//    {
//        Debug.Log (" update  hierarchyWindowChanged");
//    }

    private int row;
    private int list;

    private List textures;
    private GameObject parentObj;


    int num;
    Texture texture;
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal ();
        EditorGUILayout.LabelField (" :",GUILayout.Width(20));
        row = EditorGUILayout.IntField (row,GUILayout.Width(30));
        EditorGUILayout.LabelField (" :",GUILayout.Width(20));
        list = EditorGUILayout.IntField ( list,GUILayout.Width(30));
        EditorGUILayout.EndHorizontal ();
    
        //Debug.Log (" " + num++);
        for (int i = 0; i < 4; i++) {
            EditorGUILayout.BeginHorizontal();
            for (int j = 0; j < 3; j++) {
                texture =    EditorGUILayout.ObjectField ("", texture, typeof(Texture), true, GUILayout.Width (70)) as Texture;
                //Debug.Log (" ?" + num++ +"TextureCount"+textures.Count);
            }
            EditorGUILayout.EndHorizontal ();
        }
    

        if (GUILayout.Button (" ")) {
        //    Debug.Log (" ..."+ textures.Count);

            if (parentObj == null) {
                parentObj = new GameObject ();
                parentObj.name = "Production" + num++;
            }

            GameObject subObj = GameObject.CreatePrimitive (PrimitiveType.Quad);
            subObj.transform.Rotate (0, 180, 0);
            subObj.GetComponent ().sharedMaterial.mainTexture =texture;
            subObj.transform.SetParent (parentObj.transform);
            PrefabUtility.CreatePrefab ("Assets/Prefabs/"+ parentObj.name + ".prefab", parentObj);

        }
    }



    /*
    void OnInspectorUpdate()
    {
        //Debug.Log (" ....");
    }

    void OnHierarchyChange() {
        Debug.Log(" OnHierarchyChange");
    }
    void OnProjectChange() {
        //Debug.Log("OnProjectChange");
    }

    void OnSelectionChange()
    {
        Debug.Log (" OnSelectionChange");
    }
  */
}