当前位置: 首页>>代码示例>>C#>>正文


C# Palette.Init方法代码示例

本文整理汇总了C#中Palette.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Palette.Init方法的具体用法?C# Palette.Init怎么用?C# Palette.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Palette的用法示例。


在下文中一共展示了Palette.Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

    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", "");
//.........这里部分代码省略.........
开发者ID:ryleigh,项目名称:unity3d-pixelshitter-editor,代码行数:101,代码来源:PixelEditorScreen.cs


注:本文中的Palette.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。