public bool Init() { if(!_initialized) { // these seem to return 0 sometimes if we check them too early // so we won't consider the pixel screen initialized until we can get back a non-zero value for these if(Screen.width == 0 || Screen.height == 0) return false; int screenWidth = PlayerPrefs.GetInt("screenWidth", 800); int screenHeight = PlayerPrefs.GetInt("screenHeight", 500); screenWidth = Mathf.Max(screenHeight, 300); screenHeight = Mathf.Max(screenHeight, 300); Screen.SetResolution(screenWidth, screenHeight, false); Camera camera = GetComponent<Camera>(); camera.orthographic = true; camera.orthographicSize = 1; // ---------------------------------------------- // CANVAS // ---------------------------------------------- _canvas = gameObject.AddComponent<Canvas>(); _canvas.Init(this); _lastCanvasWidth = _canvas.pixelWidth; _lastCanvasHeight = _canvas.pixelHeight; _copiedPixels = new Color32[_canvas.pixelWidth * _canvas.pixelHeight]; _canvas.GetPixels(CurrentFrame).CopyTo(_copiedPixels, 0); _pixelDimensionsString = _canvas.pixelWidth.ToString() + "," + _canvas.pixelHeight.ToString(); _hitbox = new PixelRect(0, 0, _canvas.pixelWidth, _canvas.pixelHeight); RefreshHitboxString(); // ---------------------------------------------- // SWATCH // ---------------------------------------------- _swatch = gameObject.AddComponent<Swatch>(); _swatch.Init(this); SetCurrentColor(Color.black); // ---------------------------------------------- // PALETTE // ---------------------------------------------- _palette = gameObject.AddComponent<Palette>(); _palette.Init(this); CreateEffectPlane(); // ---------------------------------------------- // FRAME PREVIEW // ---------------------------------------------- _framePreview = gameObject.AddComponent<FramePreview>(); _framePreview.Init(this); // ---------------------------------------------- // PATTERN VIEWER // ---------------------------------------------- _patternViewer = gameObject.AddComponent<PatternViewer>(); _patternViewer.Init(this); _initialized = true; _textStyle = new GUIStyle(); _textStyle.font = Resources.Load("Fonts/04b03") as Font; _textStyle.normal.textColor = new Color(0.8f, 0.8f, 0.8f); _textStyle.fontSize = 20; _textStyleRed = new GUIStyle(_textStyle); _textStyleRed.normal.textColor = new Color(0.8f, 0.2f, 0.2f); _textStyleFocused = new GUIStyle(); _textStyleFocused.font = Resources.Load("Fonts/04b03") as Font; _textStyleFocused.normal.textColor = Color.white; Texture2D black = new Texture2D(1, 1); black.SetPixel(0, 0, Color.black); black.Apply(); _textStyleFocused.normal.background = black; _textStyleFocused.fontSize = 20; _toolMode = ToolMode.Brush; // Cursor.SetCursor(cursorBrush, Vector2.zero, CursorMode.Auto); _canvas.SetOnionSkinMode((OnionSkinMode)PlayerPrefs.GetInt("onionSkinMode", 0)); _canvas.RefreshOnionSkin(); _canvas.SetMirroringMode((MirroringMode)PlayerPrefs.GetInt("mirroringMode", 0)); _consoleText = gameObject.AddComponent<GUIText>(); _consoleText.color = Color.black; _consoleText.font = Resources.Load("Fonts/04b03") as Font; _consoleText.fontSize = 12; _consoleText.transform.position = new Vector2(0.0025f, 0); _consoleText.anchor = TextAnchor.LowerLeft; _consoleTextWrap = gameObject.AddComponent<ConsoleTextSetter>(); string animData = PlayerPrefs.GetString("animData", ""); Debug.Log("animData: " + animData); if(animData != "") LoadAnimationString(animData); } return _initialized; }