コード例 #1
0
//	void OnDestroy() {
//		isEnabled = false;
//	}

    void OnGUI()
    {
        textureStyle                      = new GUIStyle(GUI.skin.button);
        textureStyle.margin               = new RectOffset(2, 2, 2, 2);
        textureStyle.normal.background    = null;
        textureStyleAct                   = new GUIStyle(textureStyle);
        textureStyleAct.margin            = new RectOffset(0, 0, 0, 0);
        textureStyleAct.normal.background = textureStyle.active.background;

        if (!Directory.Exists(Application.dataPath + "/Tilemaps/"))
        {
            //Directory.CreateDirectory(Application.dataPath + "/Tilemaps/");
            AssetDatabase.CreateFolder("Assets", "Tilemaps");
            AssetDatabase.Refresh();
            Debug.Log("Created Tilemaps Directory");
        }
        files   = Directory.GetFiles(Application.dataPath + "/Tilemaps/", "*.png");
        options = new string[files.Length];
        EditorGUILayout.LabelField("Tile Map", GUILayout.Width(256));
        for (int i = 0; i < files.Length; i++)
        {
            options[i] = files[i].Replace(Application.dataPath + "/Tilemaps/", "");
        }
        index = EditorGUILayout.Popup(index, options, GUILayout.Width(256));
        GUILayout.BeginHorizontal();
        isGrid   = EditorGUILayout.Toggle(isGrid, GUILayout.Width(16));
        gridSize = EditorGUILayout.Vector2Field("Grid Size (0.05 minimum)", gridSize, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        isScaled = EditorGUILayout.Toggle(isScaled, GUILayout.Width(16));
        tileSize = EditorGUILayout.FloatField("Scale Tiles", tileSize, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Parent Object", GUILayout.Width(256));
        parentObj = (GameObject)EditorGUILayout.ObjectField(parentObj, typeof(GameObject), true, GUILayout.Width(256));

        EditorGUILayout.LabelField("Physics Material", GUILayout.Width(256));
        physicsMaterial = (PhysicsMaterial2D)EditorGUILayout.ObjectField(physicsMaterial, typeof(PhysicsMaterial2D), true, GUILayout.Width(256));

        GUILayout.BeginHorizontal();
        addBoxCollider = EditorGUILayout.Toggle(addBoxCollider, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Box Collider", GUILayout.Width(256));
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Layer Order", GUILayout.Width(256));

        GUILayout.BeginHorizontal();
        layerOrd  = EditorGUILayout.IntField(layerOrd, GUILayout.Width(126));
        isObjmode = EditorGUILayout.Toggle(isObjmode, GUILayout.Width(16));
        EditorGUILayout.LabelField("Layer based on Y", GUILayout.Width(110));
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Sprite Layer Name", GUILayout.Width(256));
        GUILayout.BeginHorizontal();
        layerName = EditorGUILayout.TextField(layerName, GUILayout.Width(256));
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Tag", GUILayout.Width(32));
        GUILayout.BeginHorizontal();
        tagName = EditorGUILayout.TagField(tagName, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        isDraw   = EditorGUILayout.Toggle(isDraw, GUILayout.Width(16));
        selected = (DRAWOPTION)EditorGUILayout.EnumPopup(selected, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
        GUILayout.BeginHorizontal();
        float ctr = 0.0f;

        if (options.Length > index)
        {
            allSprites = AssetDatabase.LoadAllAssetsAtPath("Assets/Tilemaps/" + options[index]).Select(x => x as Sprite).Where(x => x != null).ToArray();
            foreach (Sprite singsprite in allSprites)
            {
                if (ctr > singsprite.textureRect.x)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                ctr = singsprite.textureRect.x;
                if (activeSprite == singsprite)
                {
                    GUILayout.Button("", textureStyleAct, GUILayout.Width(singsprite.textureRect.width + 6), GUILayout.Height(singsprite.textureRect.height + 4));
                    GUI.DrawTextureWithTexCoords(new Rect(GUILayoutUtility.GetLastRect().x + 3f,
                                                          GUILayoutUtility.GetLastRect().y + 2f,
                                                          GUILayoutUtility.GetLastRect().width - 6f,
                                                          GUILayoutUtility.GetLastRect().height - 4f),
                                                 singsprite.texture,
                                                 new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
                                                          singsprite.textureRect.y / (float)singsprite.texture.height,
                                                          singsprite.textureRect.width / (float)singsprite.texture.width,
                                                          singsprite.textureRect.height / (float)singsprite.texture.height));
                }
                else
                {
                    if (GUILayout.Button("", textureStyle, GUILayout.Width(singsprite.textureRect.width + 2), GUILayout.Height(singsprite.textureRect.height + 2)))
                    {
                        activeSprite = singsprite;
                    }
                    GUI.DrawTextureWithTexCoords(GUILayoutUtility.GetLastRect(), singsprite.texture,
                                                 new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
                                                          singsprite.textureRect.y / (float)singsprite.texture.height,
                                                          singsprite.textureRect.width / (float)singsprite.texture.width,
                                                          singsprite.textureRect.height / (float)singsprite.texture.height));
                }
            }
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndScrollView();
        SceneView.RepaintAll();
    }
コード例 #2
0
ファイル: TileWindow.cs プロジェクト: LadyTusmuertos/mapmaker
	void OnGUI()
	{
		textureStyle = new GUIStyle(GUI.skin.button);
		textureStyle.margin = new RectOffset(2,2,2,2);
		textureStyle.normal.background = null;
		textureStyleAct = new GUIStyle(textureStyle);
		textureStyleAct.margin = new RectOffset(0,0,0,0);
		textureStyleAct.normal.background = textureStyle.active.background;

		if (!Directory.Exists(Application.dataPath + "/Tilemaps/"))
		{
			//Directory.CreateDirectory(Application.dataPath + "/Tilemaps/");
			AssetDatabase.CreateFolder("Assets", "Tilemaps");
			AssetDatabase.Refresh();
			Debug.Log("Created Tilemaps Directory");
		}
		files = Directory.GetFiles(Application.dataPath + "/Tilemaps/", "*.png");
		options = new string[files.Length];
		EditorGUILayout.LabelField("Tile Map", GUILayout.Width(256));
		for(int i = 0; i < files.Length; i++)
		{
			options[i] = files[i].Replace(Application.dataPath + "/Tilemaps/", "");
		}
		index = EditorGUILayout.Popup(index, options, GUILayout.Width(256));
		GUILayout.BeginHorizontal();
		isGrid = EditorGUILayout.Toggle(isGrid, GUILayout.Width(16));
		gridSize = EditorGUILayout.Vector2Field("Grid Size (0.05 minimum)", gridSize,  GUILayout.Width(236));
		GUILayout.EndHorizontal();

		EditorGUILayout.LabelField("Parent Object", GUILayout.Width(256));
		parentObj = (GameObject)EditorGUILayout.ObjectField(parentObj, typeof(GameObject),true,GUILayout.Width(256));

		GUILayout.BeginHorizontal();
		addBoxCollider = EditorGUILayout.Toggle(addBoxCollider, GUILayout.Width(16));
		EditorGUILayout.LabelField("Add Box Collider", GUILayout.Width(256));
		GUILayout.EndHorizontal();

		EditorGUILayout.LabelField("Layer Order", GUILayout.Width(256));

		GUILayout.BeginHorizontal();
		layerOrd = EditorGUILayout.IntField(layerOrd,  GUILayout.Width(126));
		isObjmode = EditorGUILayout.Toggle(isObjmode, GUILayout.Width(16));
		EditorGUILayout.LabelField("Layer based on Y", GUILayout.Width(110));
		GUILayout.EndHorizontal();

		EditorGUILayout.LabelField("Tag", GUILayout.Width(32));
		GUILayout.BeginHorizontal();
		tagName = EditorGUILayout.TagField(tagName, GUILayout.Width(236));
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		isDraw = EditorGUILayout.Toggle(isDraw, GUILayout.Width(16));
		selected = (DRAWOPTION)EditorGUILayout.EnumPopup(selected, GUILayout.Width(236));
		GUILayout.EndHorizontal();

		_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
		GUILayout.BeginHorizontal();
		float ctr = 0.0f;
		if (options.Length > index)
		{
		allSprites = AssetDatabase.LoadAllAssetsAtPath("Assets/Tilemaps/" + options[index]).Select(x => x as Sprite).Where(x => x != null).ToArray();	
		foreach(Sprite singsprite in allSprites)
		{
			if (ctr > singsprite.textureRect.x)
			{
				GUILayout.EndHorizontal();
				GUILayout.BeginHorizontal();
			}
			ctr = singsprite.textureRect.x;
			if (activeSprite == singsprite)
			{
				GUILayout.Button("", textureStyleAct, GUILayout.Width(singsprite.textureRect.width + 6), GUILayout.Height(singsprite.textureRect.height + 4));
				GUI.DrawTextureWithTexCoords(new Rect(GUILayoutUtility.GetLastRect().x + 3f,
				                                      GUILayoutUtility.GetLastRect().y + 2f,
				                                      GUILayoutUtility.GetLastRect().width - 6f,
				                                      GUILayoutUtility.GetLastRect().height - 4f),
				                             singsprite.texture,
				                             new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
				         singsprite.textureRect.y / (float)singsprite.texture.height,
				         singsprite.textureRect.width / (float)singsprite.texture.width,
				         singsprite.textureRect.height / (float)singsprite.texture.height));
			}
			else
			{
				if (GUILayout.Button("", textureStyle, GUILayout.Width(singsprite.textureRect.width + 2), GUILayout.Height(singsprite.textureRect.height + 2)))
					activeSprite = singsprite;
				GUI.DrawTextureWithTexCoords(GUILayoutUtility.GetLastRect(), singsprite.texture,
				                             new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
												         singsprite.textureRect.y / (float)singsprite.texture.height,
												         singsprite.textureRect.width / (float)singsprite.texture.width,
												         singsprite.textureRect.height / (float)singsprite.texture.height));
			}
		}
		}
		GUILayout.EndHorizontal();
		EditorGUILayout.EndScrollView();
		SceneView.RepaintAll();
	}
コード例 #3
0
    // TILEWINDOW2D GUI OPTIONS AND TOGGLES
    void OnGUI()
    {
        textureStyle                      = new GUIStyle(GUI.skin.button);
        textureStyle.margin               = new RectOffset(2, 2, 2, 2);
        textureStyle.normal.background    = null;
        textureStyleAct                   = new GUIStyle(textureStyle);
        textureStyleAct.margin            = new RectOffset(0, 0, 0, 0);
        textureStyleAct.normal.background = textureStyle.active.background;

        if (!Directory.Exists(Application.dataPath + "/Tilemaps/"))
        {
            //Directory.CreateDirectory(Application.dataPath + "/Tilemaps/");
            AssetDatabase.CreateFolder("Assets", "Tilemaps");
            AssetDatabase.Refresh();
            Debug.Log("Created Tilemaps Directory");
        }
        files   = Directory.GetFiles(Application.dataPath + "/Tilemaps/", "*.png");
        options = new string[files.Length];
        EditorGUILayout.LabelField("Tile Map", GUILayout.Width(256));
        for (int i = 0; i < files.Length; i++)
        {
            options[i] = files[i].Replace(Application.dataPath + "/Tilemaps/", "");
        }
        // GETS LIST OF SPRITES UNDER TILEMAPS FOLDER
        index = EditorGUILayout.Popup(index, options, GUILayout.Width(256));

        // GRID SIZE OPTIONS
        GUILayout.BeginHorizontal();
        // TOGGLE FOR ON/OFF GRID
        isGrid = EditorGUILayout.Toggle(isGrid, GUILayout.Width(16));
        // TEXT FOR GRID SIZE
        gridSize = EditorGUILayout.Vector2Field("Grid Size (0.05 minimum)", gridSize, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        // OPTIONS FOR PARENT OBJECT
        EditorGUILayout.LabelField("Parent Object", GUILayout.Width(256));
        parentObj = (GameObject)EditorGUILayout.ObjectField(parentObj, typeof(GameObject), true, GUILayout.Width(256));

        // OPTIONS FOR BOX COLLIDER2D
        GUILayout.BeginHorizontal();
        addBoxCollider = EditorGUILayout.Toggle(addBoxCollider, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Box Collider", GUILayout.Width(256));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A TAG DROP DOWN "VEEBEEMEE GAMES" 13 FEB 2015
        GUILayout.BeginHorizontal();
        addTag = EditorGUILayout.Toggle(addTag, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Tag", GUILayout.Width(50));
        selectedTag = EditorGUILayout.TagField("" + selectedTag, GUILayout.Width(100));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A LAYER DROP DOWN "VEEBEEMEE GAMES" 13 FEB 2015
        GUILayout.BeginHorizontal();
        addLayer = EditorGUILayout.Toggle(addLayer, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Layer", GUILayout.Width(75));
        selectedLayer = EditorGUILayout.LayerField(selectedLayer, GUILayout.Width(100));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A LAYER DROP DOWN "VEEBEEMEE GAMES" 18 FEB 2015
        GUILayout.BeginHorizontal();
        addOrderInLayer = EditorGUILayout.Toggle(addOrderInLayer, GUILayout.Width(16));
        EditorGUILayout.LabelField("Order in Layer", GUILayout.Width(100));
        orderInLayer = EditorGUILayout.IntField(orderInLayer, GUILayout.Width(126));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A LAYER DROP DOWN "VEEBEEMEE GAMES" 20 FEB 2015
        GUILayout.BeginHorizontal();
        addPrefab = EditorGUILayout.Toggle(addPrefab, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Prefab", GUILayout.Width(100));
        paintPrefab = (GameObject)EditorGUILayout.ObjectField(paintPrefab, typeof(GameObject), true, GUILayout.Width(100));
        GUILayout.EndHorizontal();

        //EditorGUILayout.LabelField("Layer Order", GUILayout.Width(256));

        //GUILayout.BeginHorizontal();
        //layerOrd = EditorGUILayout.IntField(layerOrd,  GUILayout.Width(126));
        //isObjmode = EditorGUILayout.Toggle(isObjmode, GUILayout.Width(16));
        //EditorGUILayout.LabelField("Layer based on Y", GUILayout.Width(110));
        //GUILayout.EndHorizontal();

        // TOGGLE TO PAINT / PAINTOVER / ERASE
        GUILayout.BeginHorizontal();
        isDraw   = EditorGUILayout.Toggle(isDraw, GUILayout.Width(16));
        selected = (DRAWOPTION)EditorGUILayout.EnumPopup(selected, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
        GUILayout.BeginHorizontal();
        float ctr = 0.0f;

        // CREATES INDEX BELOW FOR SPRITES IN TILEMAPS FILE SELECTED
        if (options.Length > index)
        {
            allSprites = AssetDatabase.LoadAllAssetsAtPath("Assets/Tilemaps/" + options[index]).Select(x => x as Sprite).Where(x => x != null).ToArray();
            foreach (Sprite singsprite in allSprites)
            {
                if (ctr > singsprite.textureRect.x)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                ctr = singsprite.textureRect.x;
                if (activeSprite == singsprite)
                {
                    GUILayout.Button("", textureStyleAct, GUILayout.Width(singsprite.textureRect.width + 6), GUILayout.Height(singsprite.textureRect.height + 4));
                    GUI.DrawTextureWithTexCoords(new Rect(GUILayoutUtility.GetLastRect().x + 3f,
                                                          GUILayoutUtility.GetLastRect().y + 2f,
                                                          GUILayoutUtility.GetLastRect().width - 6f,
                                                          GUILayoutUtility.GetLastRect().height - 4f),
                                                 singsprite.texture,
                                                 new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
                                                          singsprite.textureRect.y / (float)singsprite.texture.height,
                                                          singsprite.textureRect.width / (float)singsprite.texture.width,
                                                          singsprite.textureRect.height / (float)singsprite.texture.height));
                }
                else
                {
                    if (GUILayout.Button("", textureStyle, GUILayout.Width(singsprite.textureRect.width + 2), GUILayout.Height(singsprite.textureRect.height + 2)))
                    {
                        activeSprite = singsprite;
                    }
                    GUI.DrawTextureWithTexCoords(GUILayoutUtility.GetLastRect(), singsprite.texture,
                                                 new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
                                                          singsprite.textureRect.y / (float)singsprite.texture.height,
                                                          singsprite.textureRect.width / (float)singsprite.texture.width,
                                                          singsprite.textureRect.height / (float)singsprite.texture.height));
                }
            }
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndScrollView();
        SceneView.RepaintAll();
    }
コード例 #4
0
ファイル: TileWindow.cs プロジェクト: Hengga/Dungeon
    // TILEWINDOW2D GUI OPTIONS AND TOGGLES
    void OnGUI()
    {
        textureStyle = new GUIStyle(GUI.skin.button);
        textureStyle.margin = new RectOffset(2,2,2,2);
        textureStyle.normal.background = null;
        textureStyleAct = new GUIStyle(textureStyle);
        textureStyleAct.margin = new RectOffset(0,0,0,0);
        textureStyleAct.normal.background = textureStyle.active.background;

        if (!Directory.Exists(Application.dataPath + "/Tilemaps/"))
        {
            //Directory.CreateDirectory(Application.dataPath + "/Tilemaps/");
            AssetDatabase.CreateFolder("Assets", "Tilemaps");
            AssetDatabase.Refresh();
            Debug.Log("Created Tilemaps Directory");
        }
        files = Directory.GetFiles(Application.dataPath + "/Tilemaps/", "*.png");
        options = new string[files.Length];
        EditorGUILayout.LabelField("Tile Map", GUILayout.Width(256));
        for(int i = 0; i < files.Length; i++)
        {
            options[i] = files[i].Replace(Application.dataPath + "/Tilemaps/", "");
        }
        // GETS LIST OF SPRITES UNDER TILEMAPS FOLDER
        index = EditorGUILayout.Popup(index, options, GUILayout.Width(256));

        // GRID SIZE OPTIONS
        GUILayout.BeginHorizontal();
        // TOGGLE FOR ON/OFF GRID
        isGrid = EditorGUILayout.Toggle(isGrid, GUILayout.Width(16));
        // TEXT FOR GRID SIZE
        gridSize = EditorGUILayout.Vector2Field("Grid Size (0.05 minimum)", gridSize,  GUILayout.Width(236));
        GUILayout.EndHorizontal();

        // OPTIONS FOR PARENT OBJECT
        EditorGUILayout.LabelField("Parent Object", GUILayout.Width(256));
        parentObj = (GameObject)EditorGUILayout.ObjectField(parentObj, typeof(GameObject),true,GUILayout.Width(256));

        // OPTIONS FOR BOX COLLIDER2D
        GUILayout.BeginHorizontal();
        addBoxCollider = EditorGUILayout.Toggle(addBoxCollider, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Box Collider", GUILayout.Width(256));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A TAG DROP DOWN "VEEBEEMEE GAMES" 13 FEB 2015
        GUILayout.BeginHorizontal();
        addTag = EditorGUILayout.Toggle(addTag, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Tag", GUILayout.Width(50));
        selectedTag = EditorGUILayout.TagField("" + selectedTag, GUILayout.Width(100));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A LAYER DROP DOWN "VEEBEEMEE GAMES" 13 FEB 2015
        GUILayout.BeginHorizontal();
        addLayer = EditorGUILayout.Toggle(addLayer, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Layer", GUILayout.Width(75));
        selectedLayer = EditorGUILayout.LayerField(selectedLayer, GUILayout.Width(100));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A LAYER DROP DOWN "VEEBEEMEE GAMES" 18 FEB 2015
        GUILayout.BeginHorizontal();
        addOrderInLayer = EditorGUILayout.Toggle(addOrderInLayer, GUILayout.Width(16));
        EditorGUILayout.LabelField("Order in Layer", GUILayout.Width(100));
        orderInLayer = EditorGUILayout.IntField(orderInLayer,  GUILayout.Width(126));
        GUILayout.EndHorizontal();

        // OPTIONS FOR ADDING A LAYER DROP DOWN "VEEBEEMEE GAMES" 20 FEB 2015
        GUILayout.BeginHorizontal();
        addPrefab = EditorGUILayout.Toggle(addPrefab, GUILayout.Width(16));
        EditorGUILayout.LabelField("Add Prefab", GUILayout.Width(100));
        paintPrefab = (GameObject)EditorGUILayout.ObjectField(paintPrefab, typeof(GameObject),true,GUILayout.Width(100));
        GUILayout.EndHorizontal();

        //EditorGUILayout.LabelField("Layer Order", GUILayout.Width(256));

        //GUILayout.BeginHorizontal();
        //layerOrd = EditorGUILayout.IntField(layerOrd,  GUILayout.Width(126));
        //isObjmode = EditorGUILayout.Toggle(isObjmode, GUILayout.Width(16));
        //EditorGUILayout.LabelField("Layer based on Y", GUILayout.Width(110));
        //GUILayout.EndHorizontal();

        // TOGGLE TO PAINT / PAINTOVER / ERASE
        GUILayout.BeginHorizontal();
        isDraw = EditorGUILayout.Toggle(isDraw, GUILayout.Width(16));
        selected = (DRAWOPTION)EditorGUILayout.EnumPopup(selected, GUILayout.Width(236));
        GUILayout.EndHorizontal();

        _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
        GUILayout.BeginHorizontal();
        float ctr = 0.0f;

        // CREATES INDEX BELOW FOR SPRITES IN TILEMAPS FILE SELECTED
        if (options.Length > index)
        {
            allSprites = AssetDatabase.LoadAllAssetsAtPath("Assets/Tilemaps/" + options[index]).Select(x => x as Sprite).Where(x => x != null).ToArray();
            foreach(Sprite singsprite in allSprites)
            {
                if (ctr > singsprite.textureRect.x)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                ctr = singsprite.textureRect.x;
                if (activeSprite == singsprite)
                {
                    GUILayout.Button("", textureStyleAct, GUILayout.Width(singsprite.textureRect.width + 6), GUILayout.Height(singsprite.textureRect.height + 4));
                    GUI.DrawTextureWithTexCoords(new Rect(GUILayoutUtility.GetLastRect().x + 3f,
                                                          GUILayoutUtility.GetLastRect().y + 2f,
                                                          GUILayoutUtility.GetLastRect().width - 6f,
                                                          GUILayoutUtility.GetLastRect().height - 4f),
                                                 singsprite.texture,
                                                 new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
                             singsprite.textureRect.y / (float)singsprite.texture.height,
                             singsprite.textureRect.width / (float)singsprite.texture.width,
                             singsprite.textureRect.height / (float)singsprite.texture.height));
                }
                else
                {
                    if (GUILayout.Button("", textureStyle, GUILayout.Width(singsprite.textureRect.width + 2), GUILayout.Height(singsprite.textureRect.height + 2)))
                        activeSprite = singsprite;
                    GUI.DrawTextureWithTexCoords(GUILayoutUtility.GetLastRect(), singsprite.texture,
                                                 new Rect(singsprite.textureRect.x / (float)singsprite.texture.width,
                             singsprite.textureRect.y / (float)singsprite.texture.height,
                             singsprite.textureRect.width / (float)singsprite.texture.width,
                             singsprite.textureRect.height / (float)singsprite.texture.height));
                }
            }
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.EndScrollView();
        SceneView.RepaintAll();
    }
コード例 #5
0
 void OnEnable()
 {
     isEnabled = true;
     selected  = DRAWOPTION.paint;
     Editor.CreateInstance(typeof(SceneViewEventHandler));
 }