Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class DeltaFlyerImpulseWindow : MonoBehaviour {
- public Rect impulseWindow = new Rect(25, 200, 250, 150);
- // 1. If ImpulseSlider is supposed to only hold integer values, let's make it
- // be an integer type.
- public static int impulseSlider = 0;
- public static float rcsThrusterSlider = 0.0F;
- //public float impulse;
- void OnGUI () {
- impulseWindow = GUI.Window(1, impulseWindow, DrawImpulseWindow, "Sublight Control");
- networkView.RPC("SendImpulse", RPCMode.Server, impulseSlider, rcsThrusterSlider);
- }
- // 2. In order for the slider to allow sliding, we need to store its continuous
- // value as a float.
- private float impulseSliderValue;
- void DrawImpulseWindow(int windowID) {
- // 3. Synchronize the integer and floating point values, to within half a
- // unit.
- if(Mathf.Abs(impulseSliderValue - impulseSlider) > 0.5f)
- impulseSliderValue = impulseSlider;
- impulseSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 20), impulseSliderValue, -20.0F, 20.0);
- rcsThrusterSlider = GUI.HorizontalSlider(new Rect(25, 75, 100, 20), rcsThrusterSlider, -0.75F, 0.75F);
- // 4. Synchronize back again.
- impulseSlider = Mathf.Round(impulseSliderValue);
- if (GUI.Button(new Rect(150, 25, 50, 20), "Cut")) {
- impulseSlider = 0.0F;
- }
- if (GUI.Button(new Rect(150, 75, 50, 20), "Cut")) {
- rcsThrusterSlider = 0.0F;
- }
- if (GUI.Button(new Rect(125, 125, 75, 20), "Engage")) {
- networkView.RPC("SendEngageSublight", RPCMode.Server);
- }
- GUI.DragWindow(new Rect(0, 0, 10000, 20));
- }
- [RPC]
- void SendImpulse (float impulseValue, float rcsThruster) {
- //impulse = impulseValue;
- }
- [RPC]
- void SendCutImpulse () {
- }
- [RPC]
- void SendEngageSublight () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement