private void Update() { var textOffset = new Vector2(Mathf.Abs(this.Text.rectTransform.anchoredPosition.x), Mathf.Abs(this.Text.rectTransform.anchoredPosition.y)); this.Image.rectTransform.sizeDelta = this.Text.bounds.size.xy() + textOffset + this.SizeOffset; var pos = InputCtrl.MousePosition; pos = new Vector2(FunctionExtension.Remap(pos.x, 0f, Screen.width, 0f, 1920f), FunctionExtension.Remap(pos.y, 0f, Screen.height, 0f, 1080f)); this.RectTransform.anchoredPosition = pos + this.Offset + Vector2.up * this.Image.rectTransform.sizeDelta.y; }
private float GetTilingX() { if (Random.value >= 0.5f) { return(FunctionExtension.Remap(Random.value, 0f, 1f, 1f, this.LimitTiling.y)); } else { return(FunctionExtension.Remap(Random.value, 0f, 1f, this.LimitTiling.x, 1f)); } }
/// <summary> /// 设置朝向位置 /// </summary> /// <param name="targetPos">朝向位置</param> private void SetLookRotation(Vector3 targetPos) { if (this.IsReleased) { return; } var direction = (targetPos - this.transform.position).SetValue(null, 0, null); var distance = direction.magnitude; if (distance < this.DisplayDistance)// 距离过近则不显示效果 { SetRendererEnabled(false); return; } else { SetRendererEnabled(true); } this.transform.rotation = Quaternion.LookRotation(direction); this.Contrller.localPosition = this.Contrller.localPosition.SetValue(z: FunctionExtension.Remap(distance, this.RemapDistance)); }
private void Start() { var width = 1024; var height = 1024; this.tex = new Texture2D(width, height); this.Renderer.material.mainTexture = this.tex; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { var h = ((float)y / height); var xF = (float)x / width; var s = FunctionExtension.Remap(xF, 0.5f, 1f, 1, 0f); var v = FunctionExtension.Remap(xF, 0.0f, 0.5f, 0f, 1f); if (xF < 0.5f) { s = 1f; } else if (xF > 0.5f) { v = 1f; } else { s = v = 1f; } var color = Color.HSVToRGB(h, s, v); this.tex.SetPixel(x, y, color); } } this.tex.Apply(); System.IO.File.WriteAllBytes($"{Application.dataPath}/ColorSpace", this.tex.EncodeToPNG()); }
public void SetSE(float value) { this.Mixer.SetFloat("SEvolume", FunctionExtension.Remap(value, 0f, 1f, this.VolumeLimit.x, this.VolumeLimit.y)); }
public void SetBrightness(float value) { this.Exposure.keyValue.value = FunctionExtension.Remap(value, 0f, 1f, 0f, 2f); }
public void Open() { this.gameObject.SetActive(true); // 解像度 { var rs = new List <string>(); var index = 0; for (var i = 0; i < this.Resolutions.Count; i++) { rs.Add($"{this.Resolutions[i].width}x{this.Resolutions[i].height}"); if (this.Resolutions[i].Equal(Screen.currentResolution)) { index = i; } } this.ResolutionDropdown.ClearOptions(); this.ResolutionDropdown.AddOptions(rs); this.ResolutionDropdown.value = index; } this.FullScreen.isOn = Screen.fullScreen; // 垂直同步 switch (QualitySettings.vSyncCount) { case 0: this.VSync30.isOn = false; this.VSync60.isOn = false; break; case 1: this.VSync30.isOn = false; this.VSync60.isOn = true; break; case 2: this.VSync30.isOn = true; this.VSync60.isOn = false; break; default: break; } // 画质 { var qs = new List <string>(QualitySettings.names); this.QualityDropdown.ClearOptions(); this.QualityDropdown.AddOptions(qs); this.QualityDropdown.value = QualitySettings.GetQualityLevel(); } this.BrightnessSlider.value = FunctionExtension.Remap(this.Exposure.keyValue.value, 0f, 2f, 0f, 1f); this.tempBrightness = this.BrightnessSlider.value; var volume = 0f; this.Mixer.GetFloat("BGMvolume", out volume); this.BGMSlider.value = FunctionExtension.Remap(volume, this.VolumeLimit.x, this.VolumeLimit.y, 0f, 1f); this.tempBGM = this.BGMSlider.value; volume = 0f; this.Mixer.GetFloat("SEvolume", out volume); this.SESlider.value = FunctionExtension.Remap(volume, this.VolumeLimit.x, this.VolumeLimit.y, 0f, 1f); this.tempSE = this.SESlider.value; }