// Update is called once per frame void Update() { if (CurrentPattern != null) { if (CurrentPattern.Update()) { PreviewImage.sprite = CurrentPattern.GetPreviewSprite(); Previews.AllPreviews[CurrentPattern.Type].SetTexture(CurrentPattern.GetUpscaledPreview()); } if (Tools.IsToolActive(Tools.Tool.ColorPicker)) { if (Input.GetKey(KeyCode.LeftAlt)) { if (!TempToolSet) { TempToolSet = true; TempTool = Tools.CurrentTool; Tools.SwitchTool(Tools.Tool.ColorPicker); } } else { if (TempToolSet) { TempToolSet = false; Tools.SwitchTool(TempTool); TempTool = Tools.Tool.None; } } } } if (IsShown && ShowPhase < 1f) { ShowPhase = Mathf.Min(1f, ShowPhase + 1f); } if (!IsShown && ShowPhase > 0f) { ShowPhase = Mathf.Max(0f, ShowPhase - Time.deltaTime * 4f); } var currentColor = ColorPalette.GetSelectedColor(); MyCanvasGroup.alpha = ShowPhase; }
// Update is called once per frame void Update() { if (Secret != null) { if (!Secret.Dead) { Secret.Update(); CurrentPattern.CurrentSubPattern.UpdateImage(); CurrentPattern.RegeneratePreview(); } } if (Secret == null && IsShown && Input.anyKeyDown) { if (Input.GetKey(SecretCombo[CurrentSecret])) { CurrentSecret++; if (CurrentSecret == SecretCombo.Length) { CurrentSecret = 0; var layer = new RasterLayer(CurrentPattern.CurrentSubPattern, "Snake"); layer.Bitmap.CopyFrom(this.CurrentPattern.CurrentSubPattern.Bitmap); CurrentPattern.CurrentSubPattern.Layers.Add(layer); LayersChanged(); Secret = new Snake(layer.Bitmap); } } else { CurrentSecret = 0; } } try { if (CurrentPattern != null) { PreviewImage.sprite = CurrentPattern.GetPreviewSprite(); if (CurrentPattern.Update()) { PreviewImage.sprite = CurrentPattern.GetPreviewSprite(); Previews.AllPreviews[CurrentPattern.Type].SetTexture(CurrentPattern.GetUpscaledPreview()); } if (Tools.IsToolActive(Tools.Tool.Brush) && Input.GetKeyDown(KeyCode.B)) { Tools.SwitchTool(Tools.Tool.Brush); } if (Tools.IsToolActive(Tools.Tool.BucketFill) && Input.GetKeyDown(KeyCode.F)) { Tools.SwitchTool(Tools.Tool.BucketFill); } if (Tools.IsToolActive(Tools.Tool.ColorPicker) && Input.GetKeyDown(KeyCode.C)) { Tools.SwitchTool(Tools.Tool.ColorPicker); } if (Tools.IsToolActive(Tools.Tool.Eraser) && Input.GetKeyDown(KeyCode.E)) { Tools.SwitchTool(Tools.Tool.Eraser); } if (Tools.IsToolActive(Tools.Tool.Line) && Input.GetKeyDown(KeyCode.L)) { Tools.SwitchTool(Tools.Tool.Line); } if (Tools.IsToolActive(Tools.Tool.Rect) && Input.GetKeyDown(KeyCode.S)) { Tools.SwitchTool(Tools.Tool.Rect); } if (Tools.IsToolActive(Tools.Tool.Transform) && Input.GetKeyDown(KeyCode.T)) { Tools.SwitchTool(Tools.Tool.Transform); } if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.Z)) { Tools.Undo(); } if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.Y)) { Tools.Redo(); } if (Tools.IsToolActive(Tools.Tool.ColorPicker)) { if (Input.GetKey(KeyCode.LeftAlt)) { if (!TempToolSet) { TempToolSet = true; TempTool = Tools.CurrentTool; Tools.SwitchTool(Tools.Tool.ColorPicker); } } else { if (TempToolSet) { TempToolSet = false; Tools.SwitchTool(TempTool); TempTool = Tools.Tool.None; } } } } if (IsShown && ShowPhase < 1f) { ShowPhase = Mathf.Min(1f, ShowPhase + 1f); } if (!IsShown && ShowPhase > 0f) { ShowPhase = Mathf.Max(0f, ShowPhase - Time.deltaTime * 4f); } var currentColor = ColorPalette.GetSelectedColor(); MyCanvasGroup.alpha = ShowPhase; } catch (System.Exception e) { Logger.Log(Logger.Level.ERROR, "[PatternEditor] Error while updating PatternEditor: " + e.ToString()); } }