纳金网

标题: Unity 自带GUI实现 自旋转 [打印本页]

作者: 刀锋狼    时间: 2014-4-30 03:15
标题: Unity 自带GUI实现 自旋转
  1. using UnityEngine;
  2. using System.Collections;

  3. public class ro : MonoBehaviour {
  4.     public Texture2D image;//图片
  5.     public float rotspeed = 100;//速度
  6.     private float rotangle;//角度
  7.     void Update()
  8.     {
  9.         rotangle += Time.deltaTime * rotspeed;//角度
  10.     }
  11.     void OnGUI()
  12.     {
  13.         Matrix4x4 _matrix = GUI.matrix;//[size=1]变换矩阵[/size]
  14.         GUIUtility.RotateAroundPivot(rotangle, new Vector2(Screen.width/2,Screen.height/2));// 1变量 角度 2变量 旋绕点   
  15.         GUI.DrawTexture(new Rect(Screen.width/2-image.width/2,Screen.height/2-image.height/2,image.width,image.height),image);//绘画图
  16.         GUI.matrix = _matrix;//变换矩阵
  17.         GUI.Label(new Rect(10, 10, 100, 20), "转啊转啊转......");//label

  18.     }
  19. }
复制代码

作者: hyui    时间: 2014-4-30 05:05
Thank you for this share!
作者: jarryVFX    时间: 2014-4-30 08:48
Thank you for this share!
作者: jarryVFX    时间: 2014-4-30 08:48
Thank you for this share!
作者: xx232    时间: 2014-4-30 19:56
自带gui还是少用吧  不过可以试试4.6的新gui   等5吧   快了  快了




欢迎光临 纳金网 (http://c-www.narkii.com/club/) Powered by Discuz! X2.5