public void OnButtonClick(string ButtonName) { SoundController.Static.PlayClickSound(); switch (ButtonName) { case "Back": ControlSelection.SetActive(false); LevelSelection.SetActive(true); break; case "Accel": selectedMode = controls.tilt; LoadingMenu.SetActive(true); ControlSelection.SetActive(false); break; case "Button": selectedMode = controls.buttons; LoadingMenu.SetActive(true); ControlSelection.SetActive(false); break; } }
/// <summary> /// 设置控件信息 /// </summary> /// <param name="c"></param> /// <param name="o"></param> public void SetGUInfo(controls c, object o) { Dispatcher.Invoke(() => { try { switch (c) { case controls.btn_input: btn_input.Content = (string)o; break; case controls.btn_output: btn_output.Content = (string)o; break; case controls.txt_input_fps: p1.txt_input_fps.Text = (string)o; break; case controls.txt_interpolated_fps: p1.txt_interpolated_fps.Text = (string)o; break; case controls.chk_uhd: p1.chk_uhd.IsChecked = (bool)o; break; } } catch { } }); }
void Start() { makevoldemort = GameObject.Find("ScriptVoldemort").GetComponent <makevoldemort> (); makeenemy = GameObject.Find("ScriptEnemy").GetComponent <makeenemy> (); score = GameObject.Find("Harry").GetComponent <score> (); controls = GameObject.Find("Harry").GetComponent <controls> (); }
void OnCollisionEnter2D(Collision2D col) { if (col.collider.tag == "Player") { controls Player = col.collider.GetComponent <controls>(); if (this.tag == "EC") { Player.setEnergyCells(Qtd, false); } else if (this.tag == "PT") { Player.setPowerTanks(Qtd, false); } else if (this.tag == "WD") { Player.setWood(Qtd, false); } else if (this.tag == "MT") { Player.setMetal(Qtd, false); } else if (this.tag == "CN") { Player.setCannons(Qtd, false); } Destroy(gameObject); } }
// Update is called once per frame public void attractStuff(float mass, Vector2 posi, float radiusAtOne) { Collider2D[] inRadius = Physics2D.OverlapCircleAll(posi, radiusAtOne * Mathf.Abs(mass), attractedStuff); for (int i = 0; i < inRadius.Length; i++) { if (!inRadius[i].GetComponent <attracted>()) { continue; } Collider2D col = inRadius[i].GetComponent <Collider2D>(); bool inside = false; if (col.OverlapPoint(posi)) { inside = true; } Rigidbody2D rba = inRadius[i].GetComponent <Rigidbody2D>(); //Vector2 pos = col.bounds.ClosestPoint(MousePos); Vector2 pos; if (inside) { pos = inRadius[i].transform.position; } else { pos = ClosestPoint(col, posi); } Vector2 direction = posi - pos; float Gravdistance = direction.magnitude; if (Gravdistance == 0) { continue; } float minDis = inRadius[i].GetComponent <attracted>().MinDistance; if (inside) { Gravdistance = minDis; } else { Gravdistance += minDis; } controls cont = rba.GetComponent <controls>(); if (cont != null && Gravdistance < cont.jumpBreakDistance) { cont.jumping = false; } float forceMagnitude = G * (mass * rba.mass) / Mathf.Pow(Gravdistance, 2); Vector2 force = direction.normalized * forceMagnitude; rba.AddForceAtPosition(force, pos); } }
private void OnTriggerExit2D(Collider2D other) { other.transform.parent = null; if (other.tag == "Player") { c = other.GetComponent <controls>(); c.onMovingPlatform = false; mP.stopMoving(); print(c.onMovingPlatform); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { print("hit moving platform"); other.transform.parent = gameObject.transform; mP.startMoving(); c = other.GetComponent <controls>(); c.onMovingPlatform = true; print(c.onMovingPlatform); } }
public override bool checkInput(controls key) { switch (key) { case controls.nullInput: return(false); case controls.pressUp: return(checkPress(upKey)); case controls.pressLeft: return(checkPress(leftKey)); case controls.pressDown: return(checkPress(downKey)); case controls.pressRight: return(checkPress(rightKey)); case controls.holdUp: return(checkHold(upKey)); case controls.holdLeft: return(checkHold(leftKey)); case controls.holdDown: return(checkHold(downKey)); case controls.holdRight: return(checkHold(rightKey)); case controls.pressTabRight: return(checkPress(tabRight)); case controls.pressTabLeft: return(checkPress(tabLeft)); case controls.pressEnter: return(checkPress(enter)); case controls.pressBack: return(checkPress(back)); case controls.pressEnd: return(checkPress(endKey)); case controls.goTestTri: return(checkPress(gotestTri)); } return(false); }
// ADD public static bool AddControl(controls c) { Context.controls.Add(c); try { Context.SaveChanges(); } catch (DbUpdateException dbEx) { return false; } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult item in ex.EntityValidationErrors) { // Get entry DbEntityEntry entry = item.Entry; string entityTypeName = entry.Entity.GetType().Name; // Display or log error messages foreach (DbValidationError subItem in item.ValidationErrors) { string message = string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName); Console.WriteLine(message); } // Rollback changes switch (entry.State) { case EntityState.Added: entry.State = EntityState.Detached; break; case EntityState.Modified: entry.CurrentValues.SetValues(entry.OriginalValues); entry.State = EntityState.Unchanged; break; case EntityState.Deleted: entry.State = EntityState.Unchanged; break; } } return false; } Context.Entry(c).Reload(); return true; }
public override bool checkInput(controls key) { switch (key) { case controls.debug: return(checkPress(debug)); case controls.pressBack: return(checkPress(back)); case controls.pressEnter: return(checkPress(enter)); } return(false); }
public override bool checkInput(controls key) { switch (key) { case controls.debug: return(checkPress(debug)); case controls.holdRight: return(checkHold(mvRight)); case controls.holdLeft: return(checkHold(mvLeft)); } return(false); }
// DELETE public static bool DeleteControl(controls c) { controls controlToDelete = GetControlsById(c.Id); controlToDelete.IsDeleted = true; int affectedRows; try { affectedRows = Context.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult item in ex.EntityValidationErrors) { // Get entry DbEntityEntry entry = item.Entry; string entityTypeName = entry.Entity.GetType().Name; // Display or log error messages foreach (DbValidationError subItem in item.ValidationErrors) { string message = string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName); Console.WriteLine(message); } // Rollback changes switch (entry.State) { case EntityState.Added: entry.State = EntityState.Detached; break; case EntityState.Modified: entry.CurrentValues.SetValues(entry.OriginalValues); entry.State = EntityState.Unchanged; break; case EntityState.Deleted: entry.State = EntityState.Unchanged; break; } } return false; } return affectedRows > 0; }
public bool checkInput(controls key) { switch (crtInputState) { case InputState.AR_MenuKbrd: return(ar_MenuKbrd.checkInput(key)); case InputState.debugKbrd: return(debugKbrd.checkInput(key)); case InputState.playerKbrd: return(playerKbrd.checkInput(key)); } return(false); }
// Use this for initialization void Start() { preferences = preferencesObject.GetComponent <Preferences>(); controls = controlsObject.GetComponent <controls>(); modelTile = modelObject.GetComponent <ModelTile>(); settingsPrefab = GameObject.Find("settings"); isShowing = false; mask = Instantiate(Resources.Load("misc/mask"), new Vector3(0, 0, -1.5f), Quaternion.identity) as GameObject; mask.transform.localScale = new Vector3(0, 0, 0); //TilesInit dDownTiles.onValueChanged.AddListener(delegate { onDropdownTilesValueChanged(); }); List <GameObject> tiles = new List <GameObject>(Resources.LoadAll <GameObject>("tiles")); tilesNames = new List <string>(tiles.Select(x => x.name)); dDownTiles.ClearOptions(); dDownTiles.AddOptions(tilesNames); //Quality Init dDownQuality.onValueChanged.AddListener(delegate { onDropdownQualityValueChanged(); }); qualityLevels = Enum.GetNames(typeof(QualityLevel)); qualityList = new List <string>(); qualityList.AddRange(qualityLevels); dDownQuality.ClearOptions(); dDownQuality.AddOptions(qualityList); QualitySettings.SetQualityLevel(5); //FacesInit dDownFaces.onValueChanged.AddListener(delegate { onDropDownFacesValueChanged(); }); Sprite[] smth = Resources.LoadAll <Sprite>("faces"); //THIS ONE IS FOR YOU HARAMBE APPRECIATE YA GOD BLESS spriteNames = new List <string>(smth.Where(x => x.name.Contains("_0")).Select(y => y.name.TrimEnd(new char[] { '_', '0' }))); dDownFaces.ClearOptions(); dDownFaces.AddOptions(spriteNames); controls.Initiate(); modelTile.Create(dDownTiles.options[preferences.GetSavedTiles()].text, dDownFaces.options[preferences.GetSavedFaces()].text); }
public Datatype() { DataTypelist list = new DataTypelist(); list.type = "Varchar"; datatypelist.Add(list); list = new DataTypelist(); list.type = "int"; datatypelist.Add(list); list = new DataTypelist(); list.type = "Text"; datatypelist.Add(list); list = new DataTypelist(); list.type = "boolean"; datatypelist.Add(list); list = new DataTypelist(); list.type = "Date"; datatypelist.Add(list); ///////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// controls cont = new controls(); cont.type = "Text"; controllist.Add(cont); cont = new controls(); cont.type = "Radio Button"; controllist.Add(cont); cont = new controls(); cont.type = "Check Box"; controllist.Add(cont); cont = new controls(); cont.type = "DropdownList"; controllist.Add(cont); }
public Datatype() { DataTypelist list = new DataTypelist(); list.type = "Varchar"; datatypelist.Add(list); list = new DataTypelist(); list.type = "int"; datatypelist.Add(list); list = new DataTypelist(); list.type = "Text"; datatypelist.Add(list); list = new DataTypelist(); list.type = "boolean"; datatypelist.Add(list); list = new DataTypelist(); list.type = "Date"; datatypelist.Add(list); ///////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// controls cont = new controls(); cont.type = "Text"; controllist.Add(cont); cont = new controls(); cont.type = "Radio Button"; controllist.Add(cont); cont = new controls(); cont.type = "Check Box"; controllist.Add(cont); cont = new controls(); cont.type = "DropdownList"; controllist.Add(cont); }
controls GetControls() { controls ret = new controls(); //Vector<double> foo = gameObject.GetComponent<geneticAgent>().output; Vector <double> foo = gameObject.GetComponent <hillAgent>().output; if (foo[0] > 0.5) { ret.jump = 1; } else { ret.jump = 0; } if (foo[1] > 0.5) { ret.direction = 1; } else { ret.direction = 0; } return(ret); }
public override void DoWindowContents( Rect inRect ) { // set up rects Rect pickerRect = new Rect(inRect.xMin, inRect.yMin, _pickerSize, _pickerSize); Rect hueRect = new Rect(pickerRect.xMax + _margin, inRect.yMin, _sliderWidth, _pickerSize); Rect alphaRect = new Rect(hueRect.xMax + _margin, inRect.yMin, _sliderWidth, _pickerSize); Rect previewRect = new Rect(alphaRect.xMax + _margin, inRect.yMin, _previewSize, _previewSize); Rect previewOldRect = new Rect(previewRect.xMax, inRect.yMin, _previewSize, _previewSize); Rect doneRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - _fieldHeight, _previewSize * 2, _fieldHeight ); Rect setRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 2 * _fieldHeight - _margin, _previewSize - _margin / 2, _fieldHeight); Rect cancelRect = new Rect(setRect.xMax + _margin, setRect.yMin, _previewSize - _margin / 2, _fieldHeight); Rect hexRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 3 * _fieldHeight - 2 * _margin, _previewSize * 2, _fieldHeight); // draw transparency backgrounds GUI.DrawTexture( pickerRect, PickerAlphaBG ); GUI.DrawTexture( alphaRect, SliderAlphaBG ); GUI.DrawTexture( previewRect, PreviewAlphaBG ); GUI.DrawTexture( previewOldRect, PreviewAlphaBG ); // draw picker foregrounds GUI.DrawTexture( pickerRect, ColourPickerBG ); GUI.DrawTexture( hueRect, HuePickerBG ); GUI.DrawTexture( alphaRect, AlphaPickerBG ); GUI.DrawTexture( previewRect, TempPreviewBG ); GUI.DrawTexture( previewOldRect, PreviewBG ); // draw slider handles // TODO: get HSV from RGB for init of handles. Rect hueHandleRect = new Rect(hueRect.xMin - 3f , hueRect.yMin + _huePosition - _handleSize / 2, _sliderWidth + 6f, _handleSize); Rect alphaHandleRect = new Rect(alphaRect.xMin - 3f, alphaRect.yMin + _alphaPosition - _handleSize / 2, _sliderWidth + 6f, _handleSize); Rect pickerHandleRect = new Rect(pickerRect.xMin + _position.x - _handleSize / 2, pickerRect.yMin + _position.y - _handleSize / 2, _handleSize, _handleSize); GUI.DrawTexture( hueHandleRect, TempPreviewBG ); GUI.DrawTexture( alphaHandleRect, TempPreviewBG ); GUI.DrawTexture( pickerHandleRect, TempPreviewBG ); GUI.color = Color.gray; Widgets.DrawBox( hueHandleRect ); Widgets.DrawBox( alphaHandleRect ); Widgets.DrawBox( pickerHandleRect ); GUI.color = Color.white; // reset active control on mouseup if (Input.GetMouseButtonUp( 0 ) ) { _activeControl = controls.none; } // colourpicker interaction if (Mouse.IsOver( pickerRect ) ) { if( Input.GetMouseButtonDown( 0 ) ) { _activeControl = controls.colourPicker; } if( _activeControl == controls.colourPicker ) { Vector2 MousePosition = Event.current.mousePosition; Vector2 PositionInRect = MousePosition - new Vector2(pickerRect.xMin, pickerRect.yMin); PickerAction( PositionInRect ); } } // hue picker interaction if (Mouse.IsOver( hueRect ) ) { if( Input.GetMouseButtonDown( 0 ) ) { _activeControl = controls.huePicker; } if( Event.current.type == EventType.ScrollWheel ) { H -= Event.current.delta.y * UnitsPerPixel; _huePosition = Mathf.Clamp(_huePosition + Event.current.delta.y, 0f, _pickerSize); Event.current.Use(); } if( _activeControl == controls.huePicker ) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - hueRect.yMin; HueAction( PositionInRect ); } } // alpha picker interaction if (Mouse.IsOver( alphaRect ) ) { if( Input.GetMouseButtonDown( 0 ) ) { _activeControl = controls.alphaPicker; } if( Event.current.type == EventType.ScrollWheel ) { A -= Event.current.delta.y * UnitsPerPixel; _alphaPosition = Mathf.Clamp( _alphaPosition + Event.current.delta.y, 0f, _pickerSize ); Event.current.Use(); } if( _activeControl == controls.alphaPicker ) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - alphaRect.yMin; AlphaAction( PositionInRect ); } } // buttons and text field // for some reason scrolling sometimes changes text size Text.Font = GameFont.Small; if( Widgets.TextButton( doneRect, "OK" ) ) { _wrapper.Color = tempColour; if (_callback != null ) { _callback(); } this.Close(); } if( Widgets.TextButton( setRect, "Apply" ) ) { _wrapper.Color = tempColour; if( _callback != null ) { _callback(); } SetColor(); } if( Widgets.TextButton( cancelRect, "Cancel" ) ) { this.Close(); } if( _hexIn != _hexOut ) { Color inputColor = tempColour; if( TryGetColorFromHex( _hexIn, out inputColor ) ) { tempColour = inputColor; NotifyRGBUpdated(); } else { GUI.color = Color.red; } } _hexIn = Widgets.TextField( hexRect, _hexIn ); GUI.color = Color.white; }
// Update is called once per frame void Update() { if (!aiMode) { if (team == 1) { scoreUI.text = "Player 1: " + best_score.ToString("0"); } if (team == 2) { scoreUI.text = "Player 2: " + best_score.ToString("0"); } } controls mv = new controls(); if (aiMode) { if (!Dead) { //mv = GetControls(); } else { mv = new controls(); mv.direction = 0; mv.jump = 0; } } else { mv = new controls(); if (!alternate_controls) { if (Input.GetKey(KeyCode.RightArrow)) { mv.direction = 1; } else if (Input.GetKey(KeyCode.LeftArrow)) { mv.direction = -1; } else { mv.direction = 0; } } else { if (Input.GetKey(KeyCode.D)) { mv.direction = 1; } else if (Input.GetKey(KeyCode.A)) { mv.direction = -1; } else { mv.direction = 0; } } if (!alternate_controls) { if (Input.GetKeyDown(KeyCode.UpArrow)) { mv.jump = 1; } else { mv.jump = 0; } } else { if (Input.GetKeyDown(KeyCode.W)) { mv.jump = 1; } else { mv.jump = 0; } } } Grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, Ground); Move(mv.direction); Jump(mv.jump); AmIDead(); Crouch(); Shoot(); if (Dead) { death_counter++; if (!aiMode) { if (team == 1) { gameObject.transform.position = GameObject.FindGameObjectWithTag("Respawn1").transform.position; } if (team == 2) { gameObject.transform.position = GameObject.FindGameObjectWithTag("Respawn2").transform.position; } shot = false; Dead = false; } else { rigidbody.velocity = Vector2.zero; } } }
void Start() { makepotion = GameObject.Find("ScriptPotion").GetComponent <makepotion> (); score = GameObject.Find("Harry").GetComponent <score> (); controls = GameObject.Find("Harry").GetComponent <controls> (); }
private void crearArray() { controls Ent1 = new controls(); Ent1.checkbox = checkEnt1; Ent1.picture = imgEnt1; Ent1.precio = lblPrecioEnt1; Ent1.ingredientes = lblIngEnt1; Ent1.num = numEnt1; arrControles[0] = Ent1; controls Fue1 = new controls(); Fue1.checkbox = checkFue1; Fue1.picture = imgFue1; Fue1.precio = lblPrecioFue1; Fue1.ingredientes = lblIngFue1; Fue1.num = numFue1; arrControles[1] = Fue1; controls Pos1 = new controls(); Pos1.checkbox = checkPos1; Pos1.picture = imgPos1; Pos1.precio = lblPrecioPos1; Pos1.ingredientes = lblIngPos1; Pos1.num = numPos1; arrControles[2] = Pos1; controls Fue2 = new controls(); Fue2.checkbox = checkFue2; Fue2.picture = imgFue2; Fue2.precio = lblPrecioFue2; Fue2.ingredientes = lblIngFue2; Fue2.num = numFue2; arrControles[3] = Fue2; controls Pos2 = new controls(); Pos2.checkbox = checkPos2; Pos2.picture = imgPos2; Pos2.precio = lblPrecioPos2; Pos2.ingredientes = lblIngPos2; Pos2.num = numPos2; arrControles[4] = Pos2; controls Ent2 = new controls(); Ent2.checkbox = checkEnt2; Ent2.picture = imgEnt2; Ent2.precio = lblPrecioEnt2; Ent2.ingredientes = lblIngEnt2; Ent2.num = numEnt2; arrControles[5] = Ent2; controls Fue3 = new controls(); Fue3.checkbox = checkFue3; Fue3.picture = imgFue3; Fue3.precio = lblPrecioFue3; Fue3.ingredientes = lblIngFue3; Fue3.num = numFue3; arrControles[6] = Fue3; controls Pos3 = new controls(); Pos3.checkbox = checkPos3; Pos3.picture = imgPos3; Pos3.precio = lblPrecioPos3; Pos3.ingredientes = lblIngPos3; Pos3.num = numPos3; arrControles[7] = Pos3; controls Fue4 = new controls(); Fue4.checkbox = checkFue4; Fue4.picture = imgFue4; Fue4.precio = lblPrecioFue4; Fue4.ingredientes = lblIngFue4; Fue4.num = numFue4; arrControles[8] = Fue4; controls Pos4 = new controls(); Pos4.checkbox = checkPos4; Pos4.picture = imgPos4; Pos4.precio = lblPrecioPos4; Pos4.ingredientes = lblIngPos4; Pos4.num = numPos4; arrControles[9] = Pos4; controls Ent3 = new controls(); Ent3.checkbox = checkEnt3; Ent3.picture = imgEnt3; Ent3.precio = lblPrecioEnt3; Ent3.ingredientes = lblIngEnt3; Ent3.num = numEnt3; arrControles[10] = Ent3; controls Ent4 = new controls(); Ent4.checkbox = checkEnt4; Ent4.picture = imgEnt4; Ent4.precio = lblPrecioEnt4; Ent4.ingredientes = lblIngEnt4; Ent4.num = numEnt4; arrControles[11] = Ent4; }
public NextProficiencyItem(controls.ProficiencyControl reciever) { _reciever = reciever; }
private int ball_type = 0; // int to keep track of which type of ball it is. void Awake()//default both panels to false, in order to hide the screen text. { instance = this; outPanel.SetActive(false); goodshotpanel.SetActive(false); }
public DocumentChangedEventData(controls.IVisualControl vc) : base(vc, VisualControlActionKind.Changed) { }
// Update is called once per frame void Update() { if (!aiMode) { scoreUI.text = "Best score: " + best_score.ToString("0"); epUI.text = "Death Counter: " + death_counter.ToString("0"); } controls mv = new controls(); if (aiMode) { if (!Dead) { mv = GetControls(); } else { mv = new controls(); mv.direction = 0; mv.jump = 0; } } else { mv = new controls(); mv.direction = Input.GetAxis("Horizontal"); if (Input.GetKeyDown(KeyCode.UpArrow)) { mv.jump = 1; } else { mv.jump = 0; } } Grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, Ground); Move(mv.direction); Jump(mv.jump); AmIDead(); if (Dead) { death_counter++; if (!aiMode) { float score = gameObject.transform.position.x; if (score >= best_score) { best_score = score; } gameObject.transform.position = GameObject.FindGameObjectWithTag("Respawn").transform.position; Dead = false; foreach (GameObject plat in GameObject.FindGameObjectsWithTag("platform")) { Destroy(plat); } foreach (GameObject gap in GameObject.FindGameObjectsWithTag("gap")) { Destroy(gap); } GameObject.FindGameObjectWithTag("_Scene").GetComponent <spawnPlatform>().Initialize(); GameObject.FindGameObjectWithTag("laser").GetComponent <Laser>().Initialize(); gameObject.GetComponent <SpriteRenderer>().enabled = true; check_again = true; } else { rigidbody.velocity = Vector2.zero; } } queue.Dequeue(); queue.Enqueue(gameObject.transform.position.x); }
// Use this for initialization void Start() { player = FindObjectOfType <controls>(); }
// Use this for initialization void Start() { player = GetComponentInParent <controls>(); GameObject = GetComponent <DeadMenu>(); score = GetComponentInParent <ScoreManager>(); }
/// <summary> /// Set the current InputSet to use for controlling the character. /// </summary> /// <param name="inputSet">The InputSet associated with the current control scheme.</param> public void setInputSet(controls.InputSet inputSet) { inputSet_ = inputSet; }
public virtual bool checkInput(controls key) { return(false); }
public override void DoWindowContents(Rect inRect) { if (first) { Log.Message(InitialSize.ToString()); Log.Message(windowRect.ToString()); } // set up rects Rect pickerRect = new Rect(inRect.xMin, inRect.yMin, _pickerSize, _pickerSize); Rect hueRect = new Rect(pickerRect.xMax + _margin, inRect.yMin, _sliderWidth, _pickerSize); Rect alphaRect = new Rect(hueRect.xMax + _margin, inRect.yMin, _sliderWidth, _pickerSize); Rect previewRect = new Rect(alphaRect.xMax + _margin, inRect.yMin, _previewSize, _previewSize); Rect previewOldRect = new Rect(previewRect.xMax, inRect.yMin, _previewSize, _previewSize); Rect doneRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - _fieldHeight, _previewSize * 2, _fieldHeight); Rect setRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 2 * _fieldHeight - _margin, _previewSize - _margin / 2, _fieldHeight); Rect cancelRect = new Rect(setRect.xMax + _margin, setRect.yMin, _previewSize - _margin / 2, _fieldHeight); Rect hexRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 3 * _fieldHeight - 2 * _margin, _previewSize * 2, _fieldHeight); // draw transparency backgrounds GUI.DrawTexture(pickerRect, PickerAlphaBG); GUI.DrawTexture(alphaRect, SliderAlphaBG); GUI.DrawTexture(previewRect, PreviewAlphaBG); GUI.DrawTexture(previewOldRect, PreviewAlphaBG); // draw picker foregrounds GUI.DrawTexture(pickerRect, ColourPickerBG); GUI.DrawTexture(hueRect, HuePickerBG); GUI.DrawTexture(alphaRect, AlphaPickerBG); GUI.DrawTexture(previewRect, TempPreviewBG); GUI.DrawTexture(previewOldRect, PreviewBG); // draw slider handles // TODO: get HSV from RGB for init of handles. Rect hueHandleRect = new Rect(hueRect.xMin - 3f, hueRect.yMin + _huePosition - _handleSize / 2, _sliderWidth + 6f, _handleSize); Rect alphaHandleRect = new Rect(alphaRect.xMin - 3f, alphaRect.yMin + _alphaPosition - _handleSize / 2, _sliderWidth + 6f, _handleSize); Rect pickerHandleRect = new Rect(pickerRect.xMin + _position.x - _handleSize / 2, pickerRect.yMin + _position.y - _handleSize / 2, _handleSize, _handleSize); GUI.DrawTexture(hueHandleRect, TempPreviewBG); GUI.DrawTexture(alphaHandleRect, TempPreviewBG); GUI.DrawTexture(pickerHandleRect, TempPreviewBG); GUI.color = Color.gray; Widgets.DrawBox(hueHandleRect); Widgets.DrawBox(alphaHandleRect); Widgets.DrawBox(pickerHandleRect); GUI.color = Color.white; // reset active control on mouseup if (Input.GetMouseButtonUp(0)) { _activeControl = controls.none; } // colourpicker interaction if (Mouse.IsOver(pickerRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.colourPicker; } if (_activeControl == controls.colourPicker) { Vector2 MousePosition = Event.current.mousePosition; Vector2 PositionInRect = MousePosition - new Vector2(pickerRect.xMin, pickerRect.yMin); PickerAction(PositionInRect); } } // hue picker interaction if (Mouse.IsOver(hueRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.huePicker; } if (Event.current.type == EventType.ScrollWheel) { H -= Event.current.delta.y * UnitsPerPixel; _huePosition = Mathf.Clamp(_huePosition + Event.current.delta.y, 0f, _pickerSize); Event.current.Use(); } if (_activeControl == controls.huePicker) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - hueRect.yMin; HueAction(PositionInRect); } } // alpha picker interaction if (Mouse.IsOver(alphaRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.alphaPicker; } if (Event.current.type == EventType.ScrollWheel) { A -= Event.current.delta.y * UnitsPerPixel; _alphaPosition = Mathf.Clamp(_alphaPosition + Event.current.delta.y, 0f, _pickerSize); Event.current.Use(); } if (_activeControl == controls.alphaPicker) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - alphaRect.yMin; AlphaAction(PositionInRect); } } // buttons and text field // for some reason scrolling sometimes changes text size Text.Font = GameFont.Small; if (Widgets.ButtonText(doneRect, "OK")) { SetColor(); Close(); } if (Widgets.ButtonText(setRect, "Apply")) { SetColor(); } if (Widgets.ButtonText(cancelRect, "Cancel")) { Close(); } if (_hexIn != _hexOut) { Color inputColor = tempColour; if (TryGetColorFromHex(_hexIn, out inputColor)) { tempColour = inputColor; NotifyRGBUpdated(); } else { GUI.color = Color.red; } } _hexIn = Widgets.TextField(hexRect, _hexIn); GUI.color = Color.white; }
public override void DoWindowContents(Rect inRect) { // set up rects // pickers & sliders Rect pickerRect = new Rect(inRect.xMin, inRect.yMin, pickerSize, pickerSize); Rect hueRect = new Rect(pickerRect.xMax + _margin, inRect.yMin, sliderWidth, pickerSize); Rect alphaRect = new Rect(hueRect.xMax + _margin, inRect.yMin, sliderWidth, pickerSize); // previews Rect previewRect = new Rect(alphaRect.xMax + _margin, inRect.yMin, previewSize, previewSize); Rect previewOldRect = new Rect(previewRect.xMax, inRect.yMin, previewSize, previewSize); // buttons and textfields Rect okRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - _fieldHeight, previewSize * 2, _fieldHeight); Rect applyRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 2 * _fieldHeight - _margin, previewSize - _margin / 2, _fieldHeight); Rect cancelRect = new Rect(applyRect.xMax + _margin, applyRect.yMin, previewSize - _margin / 2, _fieldHeight); Rect hexRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 3 * _fieldHeight - 2 * _margin, previewSize * 2, _fieldHeight); // move ok/cancel buttons for the simple view with buttons if (!_preview && !_autoApply) { cancelRect = new Rect(inRect.xMin, pickerRect.yMax + _margin, (pickerSize - _margin) / 2, _fieldHeight); okRect = cancelRect; okRect.x += (pickerSize + _margin) / 2; } // draw transparency backgrounds GUI.DrawTexture(pickerRect, PickerAlphaBG); GUI.DrawTexture(alphaRect, SliderAlphaBG); if (_preview) { GUI.DrawTexture(previewRect, PreviewAlphaBG); GUI.DrawTexture(previewOldRect, PreviewAlphaBG); } // draw picker foregrounds GUI.DrawTexture(pickerRect, ColorPickerBG); GUI.DrawTexture(hueRect, HuePickerBG); GUI.DrawTexture(alphaRect, AlphaPickerBG); if (_preview) { GUI.DrawTexture(previewRect, TempPreviewBG); GUI.DrawTexture(previewOldRect, PreviewBG); } // draw slider handles Rect hueHandleRect = new Rect(hueRect.xMin - 3f, hueRect.yMin + _huePosition - handleSize / 2, sliderWidth + 6f, handleSize); Rect pickerHandleRect = new Rect(pickerRect.xMin + _pickerPosition.x - handleSize / 2, pickerRect.yMin + _pickerPosition.y - handleSize / 2, handleSize, handleSize); Rect alphaHandleRect = new Rect(alphaRect.xMin - 3f, alphaRect.yMin + _alphaPosition - handleSize / 2, sliderWidth + 6f, handleSize); GUI.DrawTexture(hueHandleRect, TempPreviewBG); GUI.DrawTexture(pickerHandleRect, TempPreviewBG); GUI.DrawTexture(alphaHandleRect, TempPreviewBG); // border on slider handles GUI.color = Color.gray; Widgets.DrawBox(hueHandleRect); Widgets.DrawBox(pickerHandleRect); Widgets.DrawBox(alphaHandleRect); GUI.color = Color.white; // reset active control on mouseup if (Input.GetMouseButtonUp(0)) { _activeControl = controls.none; } // colorpicker interaction if (Mouse.IsOver(pickerRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.colorPicker; } if (_activeControl == controls.colorPicker) { Vector2 MousePosition = Event.current.mousePosition; Vector2 PositionInRect = MousePosition - new Vector2(pickerRect.xMin, pickerRect.yMin); PickerAction(PositionInRect); } } // hue picker interaction if (Mouse.IsOver(hueRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.huePicker; } if (Event.current.type == EventType.ScrollWheel) { H -= Event.current.delta.y * UnitsPerPixel; _huePosition = Mathf.Clamp(_huePosition + Event.current.delta.y, 0f, pickerSize); Event.current.Use(); } if (_activeControl == controls.huePicker) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - hueRect.yMin; HueAction(PositionInRect); } } // alpha picker interaction if (Mouse.IsOver(alphaRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.alphaPicker; } if (Event.current.type == EventType.ScrollWheel) { A -= Event.current.delta.y * UnitsPerPixel; _alphaPosition = Mathf.Clamp(_alphaPosition + Event.current.delta.y, 0f, pickerSize); Event.current.Use(); } if (_activeControl == controls.alphaPicker) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - alphaRect.yMin; AlphaAction(PositionInRect); } } if (!_autoApply) { // buttons and text field // for some reason scrolling sometimes changes text size Text.Font = GameFont.Small; if (Widgets.ButtonText(okRect, "OK")) { Apply(); Close(); } if (Widgets.ButtonText(applyRect, "Apply")) { Apply(); SetColor(); } if (Widgets.ButtonText(cancelRect, "Cancel")) { Close(); } } if (_preview) { if (_hexIn != _hexOut) { if (ColorHelper.TryHexToRGB(_hexIn, ref tempColor)) { Notify_RGBUpdated(); } else { GUI.color = Color.red; } } _hexIn = Widgets.TextField(hexRect, _hexIn); } GUI.color = Color.white; }
/// <summary> /// 获取控件信息 /// </summary> /// <param name="c"></param> /// <returns></returns> public object GetGUInfo(controls c) { object o = new object(); Dispatcher.Invoke(() => { switch (c) { case controls.rbtn_v: o = rbtn_v.IsChecked; break; case controls.btn_input: o = btn_input.Content; break; case controls.btn_output: o = btn_output.Content; break; case controls.com_mode: o = p1.com_mode.SelectedIndex; ; break; case controls.com_devices: o = p1.com_devices.Text; ; break; case controls.txt_input_fps: o = p1.txt_input_fps.Text; ; break; case controls.com_times: o = p1.com_times.SelectedIndex; ; break; case controls.txt_interpolated_fps: o = p1.txt_interpolated_fps.Text; break; case controls.chk_fast_exc: o = p1.chk_fast_exc.IsChecked; break; case controls.chk_uhd: o = p1.chk_uhd.IsChecked; break; case controls.chk_vector: o = p1.chk_vector.IsChecked; break; case controls.com_type_out: o = p1.com_out_type.SelectedIndex; break; case controls.txt_dup_value: o = p1.txt_dup_value.Text; break; case controls.txt_scene_value: o = p1.txt_scene_value.Text; break; case controls.txt_static_frames: o = p1.txt_static_frames.Text; break; case controls.txt_detect_threads: o = p1.txt_detect_threads.Text; break; case controls.chk_add_audio: o = p1.chk_add_audio.IsChecked; break; case controls.txt_crf_value: o = p1.txt_crf_value.Text; break; case controls.txt_output_fps: o = p1.txt_output_fps.Text; break; case controls.chk_only_final: o = p1.chk_only_final.IsChecked; break; } }); return(o); }
public VisualControlActionEventData(controls.IVisualControl vc, VisualControlActionKind k) { VisualControl = vc; ActionKind = k; }
public override void DoWindowContents( Rect inRect ) { // set up rects // pickers & sliders Rect pickerRect = new Rect(inRect.xMin, inRect.yMin, pickerSize, pickerSize); Rect hueRect = new Rect(pickerRect.xMax + _margin, inRect.yMin, sliderWidth, pickerSize); Rect alphaRect = new Rect(hueRect.xMax + _margin, inRect.yMin, sliderWidth, pickerSize); // previews Rect previewRect = new Rect(alphaRect.xMax + _margin, inRect.yMin, previewSize, previewSize); Rect previewOldRect = new Rect(previewRect.xMax, inRect.yMin, previewSize, previewSize); // buttons and textfields Rect okRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - _fieldHeight, previewSize * 2, _fieldHeight ); Rect applyRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 2 * _fieldHeight - _margin, previewSize - _margin / 2, _fieldHeight); Rect cancelRect = new Rect(applyRect.xMax + _margin, applyRect.yMin, previewSize - _margin / 2, _fieldHeight); Rect hexRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 3 * _fieldHeight - 2 * _margin, previewSize * 2, _fieldHeight); // move ok/cancel buttons for the simple view with buttons if( !_advControls && !_autoApply ) { cancelRect = new Rect( inRect.xMin, pickerRect.yMax + _margin, ( pickerSize - _margin ) / 2, _fieldHeight ); okRect = cancelRect; okRect.x += ( pickerSize + _margin ) / 2; } // draw transparency backgrounds GUI.DrawTexture( pickerRect, PickerAlphaBG ); if( _advControls ) { GUI.DrawTexture( previewRect, PreviewAlphaBG ); GUI.DrawTexture( previewOldRect, PreviewAlphaBG ); GUI.DrawTexture( alphaRect, SliderAlphaBG ); } // draw picker foregrounds GUI.DrawTexture( pickerRect, ColourPickerBG ); GUI.DrawTexture( hueRect, HuePickerBG ); if( _advControls ) { GUI.DrawTexture( alphaRect, AlphaPickerBG ); GUI.DrawTexture( previewRect, TempPreviewBG ); GUI.DrawTexture( previewOldRect, PreviewBG ); } // draw slider handles Rect hueHandleRect = new Rect(hueRect.xMin - 3f , hueRect.yMin + _huePosition - handleSize / 2, sliderWidth + 6f, handleSize); Rect pickerHandleRect = new Rect(pickerRect.xMin + _pickerPosition.x - handleSize / 2, pickerRect.yMin + _pickerPosition.y - handleSize / 2, handleSize, handleSize); GUI.DrawTexture( hueHandleRect, TempPreviewBG ); GUI.DrawTexture( pickerHandleRect, TempPreviewBG ); // border on slider handles GUI.color = Color.gray; Widgets.DrawBox( hueHandleRect ); Widgets.DrawBox( pickerHandleRect ); GUI.color = Color.white; if( _advControls ) { Rect alphaHandleRect = new Rect(alphaRect.xMin - 3f, alphaRect.yMin + _alphaPosition - handleSize / 2, sliderWidth + 6f, handleSize); GUI.DrawTexture( alphaHandleRect, TempPreviewBG ); GUI.color = Color.gray; Widgets.DrawBox( alphaHandleRect ); GUI.color = Color.white; } #region UI interactions // reset active control on mouseup if (Input.GetMouseButtonUp( 0 ) ) { _activeControl = controls.none; } // colourpicker interaction if (Mouse.IsOver( pickerRect ) ) { if( Input.GetMouseButtonDown( 0 ) ) { _activeControl = controls.colourPicker; } if( _activeControl == controls.colourPicker ) { Vector2 MousePosition = Event.current.mousePosition; Vector2 PositionInRect = MousePosition - new Vector2(pickerRect.xMin, pickerRect.yMin); PickerAction( PositionInRect ); } } // hue picker interaction if (Mouse.IsOver( hueRect ) ) { if( Input.GetMouseButtonDown( 0 ) ) { _activeControl = controls.huePicker; } if( Event.current.type == EventType.ScrollWheel ) { H -= Event.current.delta.y * UnitsPerPixel; _huePosition = Mathf.Clamp(_huePosition + Event.current.delta.y, 0f, pickerSize); Event.current.Use(); } if( _activeControl == controls.huePicker ) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - hueRect.yMin; HueAction( PositionInRect ); } } if( _advControls ) { // alpha picker interaction if( Mouse.IsOver( alphaRect ) ) { if( Input.GetMouseButtonDown( 0 ) ) { _activeControl = controls.alphaPicker; } if( Event.current.type == EventType.ScrollWheel ) { A -= Event.current.delta.y * UnitsPerPixel; _alphaPosition = Mathf.Clamp( _alphaPosition + Event.current.delta.y, 0f, pickerSize ); Event.current.Use(); } if( _activeControl == controls.alphaPicker ) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - alphaRect.yMin; AlphaAction( PositionInRect ); } } } if( !_autoApply ) { // buttons and text field // for some reason scrolling sometimes changes text size Text.Font = GameFont.Small; if( Widgets.TextButton( okRect, "OK" ) ) { Apply(); this.Close(); } if( Widgets.TextButton( applyRect, "Apply" ) ) { Apply(); SetColor(); } if( Widgets.TextButton( cancelRect, "Cancel" ) ) { this.Close(); } } if( _advControls ) { if( _hexIn != _hexOut ) { if( ColourHelper.TryHexToRGB( _hexIn, ref tempColour ) ) { Notify_RGBUpdated(); } else { GUI.color = Color.red; } } _hexIn = Widgets.TextField( hexRect, _hexIn ); } GUI.color = Color.white; #endregion }
ThrowIfNull(controls, nameof(controls));
// Use this for initialization void Start() { player = GetComponentInParent <controls>(); }
// Start is called before the first frame update void Start() { Player = GameObject.FindGameObjectWithTag("Player").GetComponent <controls>(); }