Letní akce PHP týden
Pouze tento týden sleva až 80 % na kurzy PHP. Lze kombinovat s akcí Letní slevy na prémiový obsah!
Brno? Vypsali jsme pro vás nové termíny školení Základů programování a OOP v Brně!

GameGUI

class 3. dielu o Unity

java

using UnityEngine;
using System.Collections;
 
public class GameGUI : MonoBehaviour
{
    Vector3 rot = Vector3.zero;
    Vector3 pos = Vector3.zero;
    string x = "";
    string y = "";
    string z = "";
    Vector2 scrollPosition = Vector2.zero;
    Rect window = new Rect(0, 60, 100, 100);
    Rect window2 = new Rect(0, 160, 100, 120);
    int toolbarInt = 0;
    string[] toolbarStrings = { "0", "1", "2" };
    bool toggle = false;
 
    void Start()
    {
    }
 
    void Update()
    {
        transform.rotation = Quaternion.Euler(rot);
        transform.position = Vector3.Lerp(transform.position, pos, 1 * Time.deltaTime);
    }
   
    void OnGUI()
    {
        window = GUI.Window(0, window, WindowFunction, "Rotation");
        window2 = GUI.Window(1, window2, WindowFunction, "Movement");
        GUI.Box(new Rect(0, 0, 100, 60), "Control");
        if (GUI.Button(new Rect(5, 25, 90, 25), "Reset"))
        {
            pos = Vector3.zero;
            rot = Vector3.zero;
        }
 
        scrollPosition = GUI.BeginScrollView(new Rect(0, 400, 100, 100), scrollPosition, new Rect(0, 400, 100, 200));
 
        GUI.Button(new Rect(0, 400, 100, 20), "Button1");
        GUI.Button(new Rect(0, 420, 100, 20), "Button3");
        GUI.Button(new Rect(0, 440, 100, 20), "Button4");
        GUI.Button(new Rect(0, 460, 100, 20), "Button5");
 
        GUI.EndScrollView();
        toggle = GUI.Toggle(new Rect(0, 500, 100, 20), toggle, toggle.ToString());
        toolbarInt = GUI.Toolbar(new Rect(0, 300, 100, 25), toolbarInt, toolbarStrings);
    }
    void WindowFunction(int id)
    {
        if (id == 0)
        {
            GUI.Label(new Rect(5, 20, 9, 20), "X");
            rot.x = GUI.HorizontalSlider(new Rect(15, 25, 75, 20), rot.x, 0, 360);
            GUI.Label(new Rect(5, 40, 9, 20), "Y");
            rot.y = GUI.HorizontalSlider(new Rect(15, 45, 75, 20), rot.y, 0, 360);
            GUI.Label(new Rect(5, 60, 9, 20), "Z");
            rot.z = GUI.HorizontalSlider(new Rect(15, 65, 75, 20), rot.z, 0, 360);
            GUI.DragWindow(new Rect(0, 0, 100, 100));
        }
        if (id == 1)
        {
 
            GUI.Label(new Rect(5, 20, 9, 20), "X");
            x = GUI.TextArea(new Rect(15, 20, 75, 20), x);
            GUI.Label(new Rect(5, 40, 9, 20), "Y");
            y = GUI.TextArea(new Rect(15, 40, 75, 20), y);
            GUI.Label(new Rect(5, 60, 9, 20), "Z");
            z = GUI.TextArea(new Rect(15, 60, 75, 20), z);
 
            if (GUI.Button(new Rect(5, 85, 85, 25), "Move"))
            {
                if (x == "") x = "0";
                if (y == "") y = "0";
                if (z == "") z = "0";
                pos = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z));
            }
            GUI.DragWindow(new Rect(0, 0, 100, 120));
        }
 
    }
}

Neformátovaný

Přidáno: 15.11.2014
Expirace: Neuvedeno

Avatar
Autor: DELTA12
Aktivity (1)