void On_TouchUp(Gesture gesture) { if (gesture.fingerIndex == buttonFingerIndex) { if ((EasyTouch.IsRectUnderTouch(VirtualScreen.GetRealRect(buttonRect), true) || (isSwipeOut && buttonState == ButtonState.Press)) && enable && isActivated) { RaiseEvent(MessageName.On_ButtonUp); } buttonState = ButtonState.Up; buttonFingerIndex = -1; currentTexture = normalTexture; currentColor = buttonNormalColor; } }
/// <summary> /// Test cursor movements /// </summary> /// <param name="vs">Virtual screen</param> public static void WriteBigX(VirtualScreen vs) { vs.CleanScreen(); for (int i=0; i<vs.Height; i++) { vs.Write('X'); // already moves cursor about one vs.MoveCursor(vs.Width); // test overflow } vs.Write('\r'); // beginning of last line for (int i=0; i<vs.Height; i++) { vs.Write('X'); // already moves cursor about one vs.MoveCursor(-vs.Width); // test overflow } }
/// <summary> /// Write a byte block and strings /// </summary> /// <param name="vs">Virtual screen</param> public static void WriteBlockOperation(VirtualScreen vs) { vs.CleanScreen(); byte[] tb = Encoding.ASCII.GetBytes("This is a test output"); vs.WriteLine("New screen with test output:"); for (int i=0; i<10; i++) { vs.WriteByte(tb); } vs.WriteLine("\n"); for (int i=0; i<10; i++) { vs.WriteLine("Line output"); } }
void Start(){ if (!dynamicJoystick){ joystickCenter = joystickPositionOffset; ComputeJoystickAnchor(joyAnchor); virtualJoystick = true; } else{ virtualJoystick = false; } VirtualScreen.ComputeVirtualScreen(); startXLocalAngle = GetStartAutoStabAngle( xAxisTransform, xAI); startYLocalAngle = GetStartAutoStabAngle( yAxisTransform, yAI); }
private void VirtualScreenEventHandler_UpdateFrame(object sender, VirtualScreen e) { Vector2 Mouse = new Vector2(MousePosition.X, MousePosition.Y); for (int i = 0; i < Button_count; i++) { Vector2 position_button = new Vector2(VS_Button_Rect[i].X, VS_Button_Rect[i].Y); Vector2 size_button = new Vector2(VS_Button_Rect[i].Width, VS_Button_Rect[i].Height); VS.UI_DrawFilledRectangle(position_button, size_button, Brushes.White); VS.UI_DrawText(VS_Button_Name[i], position_button, MainFont, Brushes.Black); // check if the cursor btw mouse position is in the rect of position and size.../ if (MousePosition.X >= VS_Button_Rect[i].Left && MousePosition.X <= VS_Button_Rect[i].Right && MousePosition.Y <= VS_Button_Rect[i].Bottom && MousePosition.Y >= VS_Button_Rect[i].Top) { if (isMouseLeftDown) { VS_Button_Click[i](sender, e); } isMouseLeftDown = false; } } isMouseLeftDown = false; VS.UI_DrawFilledRectangle(Mouse, new Vector2(15, 15), Brushes.Gray); VS.UI_DrawText("Register View:", new Vector2(0, 0), MainFont, Brushes.White); if (vme != null) { string vme_registers = hString.va("%s\n%lx\n%s\n%lx\n%s\n%lx\n%s\n%lx\n%s\n%lx\n%s\n%lx\n%s\n%lx\n%s\n%lx\n%s\n%lx\n", "EAX", vme.Register.EAX, "EBX", vme.Register.EBX, "ECX", vme.Register.ECX, "EDX", vme.Register.EDX, "ESI", vme.Register.ESI, "EDI", vme.Register.EDI, "EBP", vme.Register.EBP, "ESP", vme.Register.ESP, "EIP", vme.Register.EIP); VS.UI_DrawText(vme_registers, new Vector2(0, 25), MainFont, Brushes.White); //string Code_Draw = ""; //Vector2 DrawPoint = new Vector2(100,25); //for(int i = 0; i < Code.Count; i++) //{ // Vector2 info = VS.GetTextInfo(Code[i], MainFont); // if ((info.y * i) + 25 > Width) // DrawPoint.y += info.y; // else // DrawPoint.y -= info.y*3; // Code_Draw += Code[i] + "\r"; //} //VS.UI_DrawText(Code_Draw, DrawPoint, MainFont, Brushes.White); } }
//we have multiple monitors for a client. //we may want to remove a single monitor. We should probably track a unique id per monitor that can be retrieved. public Task ClientCheckin(string client, List <VirtualScreen> screens) //TODO: I broke this function registering screens because I changed it to accept a virtual screen instead of a display. { var connectionId = Context.ConnectionId; if (screens.Count < 1) { return(Task.CompletedTask); } //add each of these displays if (_screenConfiguration.Screens.ContainsKey(client) && _screenConfiguration.Screens[client].Any()) { //this client is already configured. //TODO: we actually need to handle this - like if they add a new monitor... return(Clients.All.ScreenConfigUpdate(_screenConfiguration.Screens.Values.SelectMany(x => x).ToList())); } else { //for now, as clients start, we're just adding them to the right if (!_screenConfiguration.Screens.Any()) { foreach (var screen in screens) { var newScreen = _screenConfiguration.AddScreen(screen.X, screen.Y, screen.X, screen.Y, screen.Width, screen.Height, client, connectionId); } return(Clients.All.ScreenConfigUpdate(_screenConfiguration.Screens.Values.SelectMany(x => x).ToList())); } else { foreach (var screen in screens) { //attempt to simply add this screen in the requested position for a reconnect var newScreen = _screenConfiguration.AddScreen(screen.X, screen.Y, screen.X, screen.Y, screen.Width, screen.Height, client, connectionId); if (newScreen == null) { VirtualScreen s = _screenConfiguration.GetFurthestRight(); _screenConfiguration.AddScreenRight(s, screen.X, screen.Y, screen.Width, screen.Height, client, connectionId); } } return(Clients.All.ScreenConfigUpdate(_screenConfiguration.Screens.Values.SelectMany(x => x).ToList())); } } }
/** /// <summary> /// The main entry point for the application. /// Can be used to test the programm and run it from command line. /// </summary> [STAThread] static void Main(string[] args) { const string SEH = "--- screen ends here ---"; // coordinates are 0,0 based since we do not specify anything VirtualScreen vs = new VirtualScreen(80, 40); // simple fill VirtualScreenTest.FillScreen(vs); Console.WriteLine(vs.Hardcopy()); Console.WriteLine(SEH); Console.ReadLine(); // deleting of an area vs.CleanScreen(4,4,75,35); Console.WriteLine(vs.Hardcopy()); Console.WriteLine(SEH); Console.ReadLine(); // scrolling vs.ScrollUp(2); Console.WriteLine(vs.Hardcopy()); Console.WriteLine(SEH); Console.ReadLine(); // block operations (write to screen) VirtualScreenTest.WriteBlockOperation(vs); Console.WriteLine(vs.Hardcopy()); Console.WriteLine(SEH); Console.ReadLine(); // cursor movements VirtualScreenTest.WriteBigX(vs); Console.WriteLine(vs.Hardcopy()); Console.WriteLine(SEH); Console.ReadLine(); } // main **/ /// <summary> /// Fill the screen with a pattern /// </summary> /// <param name="vs">Virtual screen</param> public static void FillScreen(VirtualScreen vs) { byte w = 48; // 48=0 57=9 for (int y = 0; y < vs.Height; y++) { w = 48; for (int x = 0; x < vs.Width; x++) { vs.WriteByte(w); if (w<57) w++; else w = 48; } } }
protected void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { this.virtualScreen = null; this.buffer = null; } //free unmanaged objects //AdditionalCleanup(); this.disposed = true; } }
public void VirtualScreenTest() { var bitsPerPixel = 24; var bounds = new Rectangle(120, 240, 360, 480); var name = "I am a virtual screen"; var primary = true; var workArea = new Rectangle(bounds.X + 10, bounds.Y + 20, bounds.Width - 50, bounds.Height - 90); var actual = new VirtualScreen(bitsPerPixel, bounds, name, primary, workArea); Assert.AreEqual(bitsPerPixel, actual.BitsPerPixel); Assert.AreEqual(bounds, actual.Bounds); Assert.AreEqual(name, actual.DeviceName); Assert.AreEqual(primary, actual.Primary); Assert.AreEqual(workArea, actual.WorkingArea); }
public override void _Ready() { VisualServer.SetDefaultClearColor(BackgroundColor); AddChild(new WorldEnvironment() { Environment = new Godot.Environment() { BackgroundColor = BackgroundColor, BackgroundMode = Godot.Environment.BGMode.Color, }, }); AddChild(ARVROrigin = new ARVROrigin()); ARVROrigin.AddChild(ARVRCamera = new ARVRCamera() { Current = true, }); ARVROrigin.AddChild(LeftController = new ARVRController() { ControllerId = 1, }); ARVROrigin.AddChild(RightController = new ARVRController() { ControllerId = 2, }); LeftController.AddChild((Spatial)GD.Load <PackedScene>("res://OQ_Toolkit/OQ_ARVRController/models3d/OculusQuestTouchController_Left.gltf").Instance()); RightController.AddChild((Spatial)GD.Load <PackedScene>("res://OQ_Toolkit/OQ_ARVRController/models3d/OculusQuestTouchController_Right.gltf").Instance()); ARVRInterface = ARVRServer.FindInterface(OS.GetName().Equals("Android") ? "OVRMobile" : "OpenVR"); if (ARVRInterface != null && ARVRInterface.Initialize()) { GetViewport().Arvr = true; } AddChild(VirtualScreen = new VirtualScreen() { Transform = new Transform(Basis.Identity, new Vector3(0f, VirtualScreen.Height / 2f, -1f)), }); AddChild(Line3D = new Line3D() { Color = Color.Color8(255, 0, 0, 255), }); AddChild(Cube); }
public GameEngine(KeyboardInput keyboard, VirtualScreen screen) { _keyboard = keyboard; _screen = screen; _graphics = new GraphicsDeviceManager(this); _graphics.PreferredBackBufferWidth = 640; _graphics.PreferredBackBufferHeight = 480; _graphics.IsFullScreen = true; _graphics.SynchronizeWithVerticalRetrace = true; _graphics.ApplyChanges(); IsMouseVisible = !_graphics.IsFullScreen; IsFixedTimeStep = true; Window.Title = "Beneath the Surface"; Components.Add(new ScreenComponent(this)); }
public RegisterView() { InitializeComponent(); VS_Button_Name = new List <string>(); VS_Button_Rect = new List <Rectangle>(); VS_Button_Click = new List <VS_Button>(); AddButton("Compile Test", new Vector2(this.Width - 150, 10), new Vector2(200, 100), Button_CTest); AddButton("Run Test", new Vector2(this.Width - 150, 125), new Vector2(200, 100), Button_RTest); AddButton("Scripter", new Vector2(this.Width - 150, 250), new Vector2(200, 100), Button_OpenScripter); MainFont = new Font("Arial", 12); VirtualScreenEventHandler.UpdateFrame += VirtualScreenEventHandler_UpdateFrame; VS = new VirtualScreen(Handle, Width, Height, 120); VS.ClearColor = Brushes.Black; VS.RunRendererThread(); }
void On_TouchDown(Gesture gesture) { if (gesture.fingerIndex == buttonFingerIndex || (isSwipeIn && buttonState == ButtonState.None)) { if (gesture.IsInRect(VirtualScreen.GetRealRect(buttonRect), true) && enable && isActivated) { currentTexture = activeTexture; currentColor = buttonActiveColor; frame++; if ((buttonState == ButtonState.Down || buttonState == ButtonState.Press) && frame >= 2) { RaiseEvent(MessageName.On_ButtonPress); buttonState = ButtonState.Press; } if (buttonState == ButtonState.None) { buttonFingerIndex = gesture.fingerIndex; buttonState = ButtonState.Down; frame = 0; RaiseEvent(MessageName.On_ButtonDown); } } else { if (((isSwipeIn || !isSwipeIn) && !isSwipeOut) && buttonState == ButtonState.Press) { RaiseEvent(MessageName.On_ButtonUp); buttonFingerIndex = -1; currentTexture = normalTexture; currentColor = buttonNormalColor; buttonState = ButtonState.None; } else if (isSwipeOut && buttonState == ButtonState.Press) { RaiseEvent(MessageName.On_ButtonPress); buttonState = ButtonState.Press; } } } }
/// <summary> /// Calculate a near plane that defines a projection looking through a virtual window/screen. /// </summary> /// <param name="window"> /// A <see cref="VirtualScreen"/> /// The virtual window the frustum should be locked to. /// </param> /// <param name="cam"> /// A <see cref="Camera"/> /// The camera for which the projection is calculated. /// </param> /// <param name="t"> /// A <see cref="Transform"/> /// /// </param> /// <returns> /// A <see cref="NearPlane"/> /// </returns> NearPlane CalculateNearPlane(VirtualScreen window, Camera cam, Transform t) { Profiler.BeginSample("CalcNearPlane"); // align camera with window t.rotation = window.transform.rotation; // get top left and bottom right coordinates Vector3 wtl = window.tl; Vector3 wbr = window.br; NearPlane plane = new NearPlane(); // construct nearPlane Vector3 nearCenter = t.position + t.forward * cam.nearClipPlane; Plane nearPlane = new Plane(-t.forward, nearCenter); // calculate top left for near plane float dist = 0; Vector3 direction = (wtl - t.position).normalized; Ray ray = new Ray(t.position, direction); nearPlane.Raycast(ray, out dist); Vector3 ntl = -(t.InverseTransformPoint(nearCenter) - t.InverseTransformPoint((t.position + direction * dist))); plane.left = ntl.x; plane.top = ntl.y; // calculate bottom right for near plane direction = (wbr - t.position).normalized; ray = new Ray(t.position, direction); nearPlane.Raycast(ray, out dist); Vector3 nbr = -(t.InverseTransformPoint(nearCenter) - t.InverseTransformPoint((t.position + direction * dist))); plane.right = nbr.x; plane.bottom = nbr.y; plane.near = cam.nearClipPlane; plane.far = cam.farClipPlane; Profiler.EndSample(); return(plane); }
override public void OnInspectorGUI() { VirtualScreen t = target as VirtualScreen; t.displayType = (DisplayType)EditorGUILayout.EnumPopup(t.displayType); switch (t.displayType) { case DisplayType.Screen: ShowScreenGUI(); break; case DisplayType.Wall: ShowWallGUI(); break; } t.UpdateScreenSize(); }
void ShowScreenGUI() { VirtualScreen t = target as VirtualScreen; GUILayoutOption labelWidth = GUILayout.Width(120); GUILayoutOption fieldWidth = GUILayout.Width(50); GUILayoutOption sepWidth = GUILayout.Width(10); EditorGUILayout.BeginHorizontal(); GUILayout.Label("AspectRatio", labelWidth); t.aspectRatio.x = EditorGUILayout.FloatField(t.aspectRatio.x, fieldWidth); GUILayout.Label(":", sepWidth); t.aspectRatio.y = EditorGUILayout.FloatField(t.aspectRatio.y, fieldWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("screen size (diagonal in inches)", labelWidth); t.screenSize = EditorGUILayout.FloatField(t.screenSize); EditorGUILayout.EndHorizontal(); }
public override void _PhysicsProcess(float delta) { if (RightController.IsButtonPressed((int)Godot.JoystickList.VrTrigger) > 0) { if (!Shooting) { Line3D.Vertices = new Vector3[] { RightController.GlobalTransform.origin, RightController.GlobalTransform.origin + RightControllerDirection * ShotRange }; Godot.Collections.Dictionary result = GetWorld().DirectSpaceState.IntersectRay( Line3D.Vertices[0], Line3D.Vertices[1] ); GD.Print("Shooting! Time: " + DateTime.Now); if (result.Count > 0) { CollisionObject collider = (CollisionObject)result["collider"]; GD.Print( ((CollisionShape)collider.ShapeOwnerGetOwner(collider.ShapeFindOwner((int)result["shape"]))).Name ); GD.Print(result); Vector3 position = (Vector3)result["position"]; Cube.Transform = new Transform(Basis.Identity, position); Vector3 localPosition = VirtualScreen.ToLocal(position); VirtualScreen.TargetPosition = new Vector2(localPosition.x, localPosition.y); } else { GD.Print("Hit nothing! :("); } Shooting = true; } } else { Shooting = false; } }
public CheckBox(int width, int height, Texture boxTexture, Texture checkTexture, bool check, FontRender fontRender, string str) : base(width, height) { var textTex = fontRender.GetTexture(str); // 土台の描画。 var boxTextureSize = boxTexture.TextureSize; var screen = new VirtualScreen(Width, Height); Checked = check; // 文字の描画 textTex.ReferencePoint = ReferencePoint.CenterLeft; screen.Draw(textTex, boxTextureSize.width, height / 2); Texture = screen.Texture; Texture.ReferencePoint = ReferencePoint.CenterLeft; CheckTex = checkTexture; CheckTex.ReferencePoint = ReferencePoint.CenterLeft; Clicked += CheckBox_Clicked; }
private void InitTouch() { bool realTouch = false; if (Application.platform == RuntimePlatform.Android) { realTouch = true; } GameObject go = gameObject; touchBase = go.AddComponent <TouchBase>(); virtualScreen = go.AddComponent <VirtualScreen>(); TouchBase.SetUseRealTouch(realTouch); TouchBase.OnDragStart += OnDragStart; TouchBase.OnDrag += OnDrag; TouchBase.OnDragEnd += OnDragEnd; TouchBase.OnSwipeStart += OnSwipeStart; TouchBase.OnSwipe += OnSwipe; TouchBase.OnSwipeEnd += OnSwipeEnd; TouchBase.OnDoubleTap += OnDoubleTap; }
/// <summary> /// Creats a NearPlane based on the given VirtualScreen and transform. /// This function comes from the old CAVE Asset. /// </summary> /// <param name="window">VirtualScreen</param> /// <param name="targetTransform">Transform</param> /// <returns></returns> private NearPlane CalculateNearPlane(VirtualScreen window, Transform targetTransform) { NearPlane nearPlane = new NearPlane(); Vector3 nearCenter = targetTransform.position + targetTransform.forward * cam.nearClipPlane; Plane plane = new Plane(-targetTransform.forward, nearCenter); float distance = 0.0f; Vector3 direction; Ray ray; // calculate top left for nearPlane direction = (window.topLeft - targetTransform.position).normalized; ray = new Ray(targetTransform.position, direction); plane.Raycast(ray, out distance); Vector3 nearTopLeft = -(targetTransform.InverseTransformPoint(nearCenter) - targetTransform.InverseTransformPoint((targetTransform.position + direction * distance))); nearPlane.left = nearTopLeft.x; nearPlane.top = nearTopLeft.y; // calculate bottom right for nearPlane direction = (window.bottomRight - targetTransform.position).normalized; ray = new Ray(targetTransform.position, direction); plane.Raycast(ray, out distance); Vector3 nearBottomRight = -(targetTransform.InverseTransformPoint(nearCenter) - targetTransform.InverseTransformPoint((targetTransform.position + direction * distance))); nearPlane.right = nearBottomRight.x; nearPlane.bottom = nearBottomRight.y; // near and far clipPlane for nearPlane nearPlane.near = cam.nearClipPlane; nearPlane.far = cam.farClipPlane; return(nearPlane); }
//TODO: rewrite this. there are really only 3 outcomes of this function. // 1) hide the mouse, show the mouse, replay the mouse from a remote server // 2) translate virtual coords to screen coords. // 2) update a field tracking the last local position of the mouse -WHY DON'T I JUST ASK THE OS???? //based on the current position of the virtual coordinates //decide whether to hide the mouse, pass the coords to the hook, or handle the event, or some combo. public CoordinateUpdateResult UpdateVirtualMouseCoordinates(MouseMoveEventArgs e) { int deltaX, deltaY, newX, newY; //calculate the change from previous stored coordinates newX = State.VirtualX + (deltaX = e.Mouse.X - State.LastPositionX); newY = State.VirtualY + (deltaY = e.Mouse.Y - State.LastPositionY); var s = ScreenConfiguration.ValidVirtualCoordinate(newX, newY); //Console.WriteLine("hook " + e.Mouse.X + "," + e.Mouse.Y + " : delta " + deltaX + "," + deltaY + " : virtual " + ClientState._virtualX + ", " + ClientState._virtualY + ", lastpos:"+ClientState._lastPositionX+","+ClientState._lastPositionY); if (s == null) { e.Handled = !State.CurrentClientFocused; return(CoordinateUpdateResult.Empty); } else { if (s.Client == State.ClientName) { State.VirtualX = newX; State.VirtualY = newY; State.LastPositionX = Math.Abs(newX - s.X) + s.LocalX; State.LastPositionY = Math.Abs(newY - s.Y) + s.LocalY; //we previous weren't focused, but now we are if (!State.CurrentClientFocused) { e.Handled = true; State.CurrentClientFocused = true; System.Windows.Input.Mouse.SetCursor(System.Windows.Input.Cursors.Arrow); return(CoordinateUpdateResult.ValidMouseMove); //Console.WriteLine("regaining focus: " + localX + ","+ localY); //mark this as handled since we manually set the cursor and don't want it to rubberband around } return(CoordinateUpdateResult.ValidCoordinate); } else if (State.CurrentClientFocused) { State.VirtualX = newX; State.VirtualY = newY; //we have moved off screen now - hide the mouse VirtualScreen screen = ScreenConfiguration[State.ClientName].First(); //hide mouse //Console.WriteLine("detected coordinates outside of our current screen - hiding mouse at " + localMaxX + "," + localMaxY); //_hook.Hook.SetMousePos((int)localMaxX, (int)localMaxY); State.LastPositionX = screen.Width - 1; State.LastPositionY = screen.Height - 1; //Console.WriteLine("Setting last known position of mouse to " + localMaxX + "," + localMaxY); //we are offscreen State.CurrentClientFocused = false; e.Handled = true; return(CoordinateUpdateResult.ValidMouseMove); } else { State.VirtualX += deltaX * s.ScaleX; State.VirtualY += deltaY * s.ScaleY; e.Handled = true; return(CoordinateUpdateResult.ValidCoordinate); } } }
private void Button_RTest(object sender, VirtualScreen e) { vme = new VM_Executor(@"E:\VisualStudios\VM\VM\bin\Debug\basic_test.compiled"); //auto run. :) }
void OnGUI() { if (enable) { GUI.depth = guiDepth; useGUILayout = isUseGuiLayout; VirtualScreen.ComputeVirtualScreen(); VirtualScreen.SetGuiScaleMatrix(); if (normalTexture != null && activeTexture != null) { ComputeButtonAnchor(anchor); if (normalTexture != null) { if (Application.isEditor && !Application.isPlaying) { currentTexture = normalTexture; } if (showDebugArea && Application.isEditor && selected && !Application.isPlaying) { GUI.Box(buttonRect, ""); } if (currentTexture != null) { if (isActivated) { GUI.color = currentColor; if (Application.isPlaying) { EasyTouch.instance.reservedVirtualAreas.Remove(buttonRect); EasyTouch.instance.reservedVirtualAreas.Add(buttonRect); } } else { GUI.color = new Color(currentColor.r, currentColor.g, currentColor.b, 0.2f); if (Application.isPlaying) { EasyTouch.instance.reservedVirtualAreas.Remove(buttonRect); } } GUI.DrawTexture(buttonRect, currentTexture); GUI.color = Color.white; } } } } else { if (Application.isPlaying) { EasyTouch.instance.reservedVirtualAreas.Remove(buttonRect); } } }
/// <summary> /// GUIのボタンを描画する。 /// </summary> /// <param name="background">ボタンの背景として使用する画像。正方形でなければならない。</param> /// <param name="content">ボタンの中身。</param> /// <param name="width">(オプション)横のサイズ。</param> /// <param name="height">(オプション)縦のサイズ。</param> public Button(ITextureReturnable background, ITextureReturnable content, int?width = null, int?height = null) : base(width ?? content.GetTexture().TextureSize.width, height ?? content.GetTexture().TextureSize.height) { OnMouseDown += Button_OnMouseDown; OnMouseUp += Button_OnMouseUp; var contentTex = content.GetTexture(); var backTex = background.GetTexture(); // ボタンの土台の描画。 var buttonTextureSize = backTex.TextureSize; var oneSize = (buttonTextureSize.width / 3, buttonTextureSize.height / 3); var screen = new VirtualScreen(Width, Height); screen.Draw(() => { // 左上 backTex.ReferencePoint = ReferencePoint.TopLeft; backTex.ScaleX = 1.0f; backTex.ScaleX = 1.0f; backTex.Draw(0, 0, new Rectangle(0, 0, oneSize.Item1, oneSize.Item2)); // 中央上 backTex.ReferencePoint = ReferencePoint.TopCenter; backTex.ScaleX = (float)(1.0 * (Width - oneSize.Item1 * 2) / oneSize.Item1); backTex.Draw(Width / 2, 0, new Rectangle(oneSize.Item1, 0, oneSize.Item1, oneSize.Item2)); // 右上 backTex.ReferencePoint = ReferencePoint.TopRight; backTex.ScaleX = 1.0f; backTex.Draw(Width, 0, new Rectangle(oneSize.Item1 * 2, 0, oneSize.Item1, oneSize.Item2)); // 左中央 backTex.ReferencePoint = ReferencePoint.CenterLeft; backTex.ScaleY = (float)(1.0 * (Height - oneSize.Item2 * 2) / oneSize.Item2); backTex.Draw(0, Height / 2, new Rectangle(0, oneSize.Item2, oneSize.Item1, oneSize.Item2)); // 中央 backTex.ReferencePoint = ReferencePoint.Center; backTex.ScaleX = (float)(1.0 * (Width - oneSize.Item1 * 2) / oneSize.Item1); backTex.Draw(Width / 2, Height / 2, new Rectangle(oneSize.Item1, oneSize.Item2, oneSize.Item1, oneSize.Item2)); // 右中央 backTex.ReferencePoint = ReferencePoint.CenterRight; backTex.ScaleX = 1.0f; backTex.Draw(Width, Height / 2, new Rectangle(oneSize.Item1 * 2, oneSize.Item2, oneSize.Item1, oneSize.Item2)); // 左下 backTex.ReferencePoint = ReferencePoint.BottomLeft; backTex.ScaleY = 1.0f; backTex.Draw(0, Height, new Rectangle(0, oneSize.Item2 * 2, oneSize.Item1, oneSize.Item2)); // 中央下 backTex.ReferencePoint = ReferencePoint.BottomCenter; backTex.ScaleX = (float)(1.0 * (Width - oneSize.Item1 * 2) / oneSize.Item1); backTex.Draw(Width / 2, Height, new Rectangle(oneSize.Item1, oneSize.Item2 * 2, oneSize.Item1, oneSize.Item2)); // 右下 backTex.ReferencePoint = ReferencePoint.BottomRight; backTex.ScaleX = 1.0f; backTex.Draw(Width, Height, new Rectangle(oneSize.Item1 * 2, oneSize.Item2 * 2, oneSize.Item1, oneSize.Item2)); // 文字の描画 contentTex.ReferencePoint = ReferencePoint.Center; contentTex.Draw(Width / 2, Height / 2); }); Texture = screen.Texture; DownAnimation = new Animation.EaseOut(100, 95, 1000 * 250); UpAnimation = new Animation.EaseOut(95, 100, 1000 * 250); Texture.ReferencePoint = ReferencePoint.Center; }
private void Button_OpenScripter(object sender, VirtualScreen e) { }
protected virtual void CleanupCode(VirtualScreen screen, int dx, int dy) { CleanUpImpl(screen, dx, dy, 0); }
/// <summary> /// Calculate a near plane that defines a projection looking through a virtual window/screen. /// </summary> /// <param name="window"> /// A <see cref="VirtualScreen"/> /// The virtual window the frustum should be locked to. /// </param> /// <param name="cam"> /// A <see cref="Camera"/> /// The camera for which the projection is calculated. /// </param> /// <param name="t"> /// A <see cref="Transform"/> /// /// </param> /// <returns> /// A <see cref="NearPlane"/> /// </returns> NearPlane CalculateNearPlane(VirtualScreen window, Camera cam, Transform t) { Profiler.BeginSample("CalcNearPlane"); // align camera with window t.rotation = window.transform.rotation; // get top left and bottom right coordinates Vector3 wtl = window.tl; Vector3 wbr = window.br; NearPlane plane = new NearPlane(); // construct nearPlane Vector3 nearCenter = t.position + t.forward * cam.nearClipPlane; Plane nearPlane = new Plane(-t.forward, nearCenter); // calculate top left for near plane float dist = 0; Vector3 direction = (wtl - t.position).normalized; Ray ray = new Ray(t.position, direction); nearPlane.Raycast(ray, out dist); Vector3 ntl = -(t.InverseTransformPoint(nearCenter) - t.InverseTransformPoint((t.position + direction * dist))); plane.left = ntl.x; plane.top = ntl.y; // calculate bottom right for near plane direction = (wbr - t.position).normalized; ray = new Ray(t.position, direction); nearPlane.Raycast(ray, out dist); Vector3 nbr = -(t.InverseTransformPoint(nearCenter) - t.InverseTransformPoint((t.position + direction * dist))); plane.right = nbr.x; plane.bottom = nbr.y; plane.near = cam.nearClipPlane; plane.far = cam.farClipPlane; Profiler.EndSample(); return plane; }
protected override void CleanupCode(VirtualScreen screen, int dx, int dy) { CleanUpImpl(screen, dx, dy, 1); }
public override void AddToVirtualScreen(VirtualScreen screen, int dx = 0, int dy = 0) { base.AddToVirtualScreen(screen, dx, dy); MakeBorder(screen); }
public abstract void AddToVirtualScreen(VirtualScreen screen, int dx = 0, int dy = 0);
void OnGUI(){ if (enable){ GUI.depth = guiDepth; useGUILayout = isUseGuiLayout; if (dynamicJoystick && Application.isEditor && !Application.isPlaying){ switch (area){ case DynamicArea.Bottom: ComputeJoystickAnchor(JoystickAnchor.LowerCenter); break; case DynamicArea.BottomLeft: ComputeJoystickAnchor(JoystickAnchor.LowerLeft); break; case DynamicArea.BottomRight: ComputeJoystickAnchor(JoystickAnchor.LowerRight); break; case DynamicArea.FullScreen: ComputeJoystickAnchor(JoystickAnchor.MiddleCenter); break; case DynamicArea.Left: ComputeJoystickAnchor(JoystickAnchor.MiddleLeft); break; case DynamicArea.Right: ComputeJoystickAnchor(JoystickAnchor.MiddleRight); break; case DynamicArea.Top: ComputeJoystickAnchor(JoystickAnchor.UpperCenter); break; case DynamicArea.TopLeft: ComputeJoystickAnchor(JoystickAnchor.UpperLeft); break; case DynamicArea.TopRight: ComputeJoystickAnchor(JoystickAnchor.UpperRight); break; } } if (Application.isEditor && !Application.isPlaying){ VirtualScreen.ComputeVirtualScreen(); ComputeJoystickAnchor( joyAnchor); } VirtualScreen.SetGuiScaleMatrix(); // area zone if ((showZone && areaTexture!=null && !dynamicJoystick) || (showZone && dynamicJoystick && virtualJoystick && areaTexture!=null) || (dynamicJoystick && Application.isEditor && !Application.isPlaying)){ if (isActivated){ GUI.color = areaColor; if (Application.isPlaying && !dynamicJoystick){ EasyTouch.RemoveReservedArea( areaRect ); EasyTouch.AddReservedArea( areaRect ); } } else{ GUI.color = new Color(areaColor.r,areaColor.g,areaColor.b,0.2f); if (Application.isPlaying && !dynamicJoystick){ EasyTouch.RemoveReservedArea( areaRect ); } } if (showDebugRadius && Application.isEditor){ GUI.Box( areaRect,""); } GUI.DrawTexture( areaRect, areaTexture,ScaleMode.StretchToFill,true); } // area touch if ((showTouch && touchTexture!=null && !dynamicJoystick)|| (showTouch && dynamicJoystick && virtualJoystick && touchTexture!=null) || (dynamicJoystick && Application.isEditor && !Application.isPlaying)){ if (isActivated){ GUI.color = touchColor; } else{ GUI.color = new Color(touchColor.r,touchColor.g,touchColor.b,0.2f); } GUI.DrawTexture( new Rect(anchorPosition.x + joystickCenter.x+(joystickTouch.x -touchSize) ,anchorPosition.y + joystickCenter.y-(joystickTouch.y+touchSize),touchSize*2,touchSize*2), touchTexture,ScaleMode.ScaleToFit,true); } // dead zone if ((showDeadZone && deadTexture!=null && !dynamicJoystick)|| (showDeadZone && dynamicJoystick && virtualJoystick && deadTexture!=null) || (dynamicJoystick && Application.isEditor && !Application.isPlaying)){ GUI.DrawTexture( deadRect, deadTexture,ScaleMode.ScaleToFit,true); } GUI.color = Color.white; } else{ EasyTouch.RemoveReservedArea( areaRect ); } }