Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DeltaFlyerImpulseWindow : MonoBehaviour {
  5.    
  6.     public Rect impulseWindow = new Rect(25, 200, 250, 150);
  7.  
  8.         // 1. If ImpulseSlider is supposed to only hold integer values, let's make it
  9.         //    be an integer type.
  10.     public static int impulseSlider = 0;
  11.  
  12.     public static float rcsThrusterSlider = 0.0F;
  13.    
  14.     //public float impulse;
  15.    
  16.     void OnGUI () {
  17.         impulseWindow = GUI.Window(1, impulseWindow, DrawImpulseWindow, "Sublight Control");
  18.         networkView.RPC("SendImpulse", RPCMode.Server, impulseSlider, rcsThrusterSlider);
  19.     }
  20.  
  21.         // 2. In order for the slider to allow sliding, we need to store its continuous
  22.         //    value as a float.
  23.         private float impulseSliderValue;
  24.    
  25.     void DrawImpulseWindow(int windowID) {
  26.                
  27.                 // 3. Synchronize the integer and floating point values, to within half a
  28.                 //    unit.
  29.                 if(Mathf.Abs(impulseSliderValue - impulseSlider) > 0.5f)
  30.                    impulseSliderValue = impulseSlider;
  31.  
  32.         impulseSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 20), impulseSliderValue, -20.0F, 20.0);
  33.         rcsThrusterSlider = GUI.HorizontalSlider(new Rect(25, 75, 100, 20), rcsThrusterSlider, -0.75F, 0.75F);
  34.  
  35.                 // 4. Synchronize back again.
  36.                 impulseSlider = Mathf.Round(impulseSliderValue);
  37.        
  38.         if (GUI.Button(new Rect(150, 25, 50, 20), "Cut")) {
  39.             impulseSlider = 0.0F;
  40.         }
  41.         if (GUI.Button(new Rect(150, 75, 50, 20), "Cut")) {
  42.             rcsThrusterSlider = 0.0F;
  43.         }
  44.         if (GUI.Button(new Rect(125, 125, 75, 20), "Engage")) {
  45.             networkView.RPC("SendEngageSublight", RPCMode.Server);
  46.         }
  47.        
  48.         GUI.DragWindow(new Rect(0, 0, 10000, 20));
  49.     }
  50.    
  51.     [RPC]
  52.     void SendImpulse (float impulseValue, float rcsThruster) {
  53.         //impulse = impulseValue;
  54.     }
  55.    
  56.     [RPC]
  57.     void SendCutImpulse () {
  58.     }
  59.    
  60.     [RPC]
  61.     void SendEngageSublight () {
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement