unity点击下一张图片_求助,有没有大神知道点击按钮后就弹出一张图片的代码怎么写呀,网上找了很多但都不成功的...

这篇博客探讨了在Unity中如何编写代码以实现在点击按钮后显示一张图片。作者提供了部分代码示例,包括加载资源、创建按钮以及在GUI上绘制图片的方法。尽管遇到了一些困难,但博主分享了其尝试解决这个问题的步骤。
摘要由CSDN通过智能技术生成

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

using UnityEngine;

using System.Collections;

public class Button : MonoBehaviour {

Texture2D texSingle;

Object[] texAll;

//var windowRect;

// Use this for initialization

void Start () {

//var mySkin:GUIskin;

//windowRect=Rect(200,200,200,200);

texAll=Resources.LoadAll("木板");

}

// Update is called once per frame

void Update () {

}

void OnGUI()

{

GUI.color = Color.black;

GUI.backgroundColor = Color.clear;

GUI.skin.button.fontSize=25;

GUI.skin.button.fontStyle = FontStyle.Bold;

//GUI.skin = mySkin;

if (GUI.Button (new Rect (630, 280, 120, 50), "开始游戏")) {

Application.LoadLevel(1);

}

//normal color A=0;

if (GUI.Button (new Rect (630, 350, 120, 50), "故事简介")) {

texSingle=(Texture2D)texAll[0];

GUI.DrawTexture(new Rect(630, 350, 120, 50),(Texture2D)texSingle,ScaleMode.StretchToFill,true,0);

}

//GUI.DrawTexture (new Rect (110, 130, 150, 150),(Texture2D) texAll, ScaleMode.StretchToFill, true, 0);

if (GUI.Button (new Rect (630, 440, 120, 30), "玩法说明")) {

Application.LoadLevel (1);

}

if (GUI.Button (new Rect (630, 500, 120, 30), "退出游戏")) {

Application.Quit();

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值