示例#1
0
        public override void OnInspectorGUI()
        {
            FizzikSprite obj = (FizzikSprite)target;

            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField("Frame Count: " + obj.frames.Count);
            EditorGUILayout.LabelField("Layer 0 pixeldata:");
            EditorGUILayout.LabelField(obj.getFrame(0).getLayer(0).pixels.ToString());

            EditorGUILayout.EndVertical();
        }
        public void checkLayerRectsForLeftMouseClick(Vector2 clickPos)
        {
            FizzikSprite sprite = editor.getWorkingSprite();
            FizzikFrame  frame  = sprite.getCurrentFrame();

            for (int i = 0; i < layerRects.Count; i++)
            {
                Rect layerRect = layerRects[i];

                //Offset layerRect by its container's rect
                Vector2 offsetVec    = layerRect.position + layersOffsetRect.position - scrollPosition;
                Rect    relativeRect = new Rect(offsetVec.x, offsetVec.y, layerRect.width, layerRect.height);

                if (layersScrollRect.Contains(clickPos) && relativeRect.Contains(clickPos))
                {
                    //Debug.Log("Layer Subwindow Left Clicked : " + i);
                    frame.setCurrentLayer(i);
                    return;
                }
            }
        }
示例#3
0
        public override void handleGUI(int windowID)
        {
            base.handleGUI(windowID);

            Event e = Event.current;

            Color prevColor = GUI.color;

            FizzikSprite sprite = editor.getWorkingSprite();

            //Set initial color
            if (!colorInit && sprite != null)
            {
                color     = sprite.recentColors[0];
                colorInit = true;
            }

            EditorGUILayout.BeginVertical();

            //Define styles
            GUIStyle btnstyle = new GUIStyle(GUI.skin.button);

            btnstyle.fixedWidth         = 20;
            btnstyle.fixedHeight        = 20;
            btnstyle.margin             = new RectOffset(1, 2, 2, 2);
            btnstyle.border             = new RectOffset(1, 1, 1, 1);
            btnstyle.normal.background  = btnImage;
            btnstyle.hover.background   = btnImage;
            btnstyle.active.background  = btnImage;
            btnstyle.focused.background = btnImage;

            GUIStyle btnstyle2 = new GUIStyle(btnstyle);

            btnstyle2.fixedWidth  = 13;
            btnstyle2.fixedHeight = 13;

            //Draw Default Color Palette
            for (int j = 0; j < DEFAULTCOLORS_ROWS; j++)
            {
                EditorGUILayout.BeginHorizontal();

                for (int i = 0; i < DEFAULTCOLORS_COLUMNS; i++)
                {
                    Color defColor = getDefaultColor(i, j);

                    GUI.color = defColor;

                    if (GUILayout.Button("", btnstyle))
                    {
                        if (isGUIButtonClick())
                        {
                            color = defColor;
                        }
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            //Draw recently selected colors
            if (sprite != null)
            {
                GUILayout.Space(4f);

                GUILayout.BeginHorizontal();

                GUILayout.Space(2f);

                Color[] recentColors = sprite.recentColors;
                for (int i = 0; i < recentColors.Length; i++)
                {
                    GUI.color = recentColors[i];

                    if (GUILayout.Button("", btnstyle2))
                    {
                        if (isGUIButtonClick())
                        {
                            color = recentColors[i];
                        }
                    }
                }

                GUILayout.EndHorizontal();
            }

            //Draw currently selected color
            GUI.color = Color.white;

            GUILayout.Space(8f);

            color = EditorGUILayout.ColorField(color);



            EditorGUILayout.EndVertical();

            GUI.color = prevColor;

            dragWindow();
        }
        public override void handleGUI(int windowID)
        {
            base.handleGUI(windowID);

            Event e = Event.current;

            //Layer layouting variables
            FizzikSprite       sprite = editor.getWorkingSprite();
            FizzikFrame        frame  = sprite.getCurrentFrame();
            List <FizzikLayer> layers = frame.layers;

            float w  = currentRect.width;
            float h  = currentRect.height;
            float hw = w / 2;
            float hh = h / 2;

            //Styles
            GUIStyle scrollViewStyle = new GUIStyle(GUI.skin.scrollView);

            GUIStyle layersStyle = new GUIStyle();

            layersStyle.normal.background = layersBackgroundTex;

            GUIStyle layerStyle = new GUIStyle(GUI.skin.button);

            layerStyle.normal.background = layerBackgroundTex;

            GUIStyle layerSelectedStyle = new GUIStyle(layerStyle);

            layerSelectedStyle.normal.background = layerSelectedBackgroundTex;

            GUIStyle layerNameStyle = new GUIStyle();

            layerNameStyle.fixedWidth = LAYER_NAME_WIDTH;
            layerNameStyle.clipping   = TextClipping.Clip;

            GUIStyle layerOverallToolbarStyle = new GUIStyle();

            //Begin GUI
            GUILayout.BeginVertical();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, scrollViewStyle);

            //Begin Layers
            GUILayout.BeginVertical(layersStyle);

            layerRects.Clear();

            for (int i = layers.Count() - 1; i >= 0; i--)
            {
                FizzikLayer layer = layers[i];

                //Begin Layer
                if (frame.getCurrentLayer() == layer)
                {
                    GUILayout.BeginHorizontal(layerSelectedStyle, GUILayout.Height(LAYER_HEIGHT));
                }
                else
                {
                    GUILayout.BeginHorizontal(layerStyle, GUILayout.Height(LAYER_HEIGHT));
                }

                GUILayout.Box(layer.texture, new GUIStyle(GUI.skin.button), GUILayout.Width(LAYER_HEIGHT), GUILayout.Height(LAYER_HEIGHT));
                GUILayout.Label(layer.name, layerNameStyle);

                GUILayout.EndHorizontal();
                layerRects.Insert(0, GUILayoutUtility.GetLastRect()); //Insert to front so that the layerRects list is in correct layer order
                //End Layer
            }

            GUILayout.EndVertical();
            //End Layers

            //Draw layerRects DEBUG TODO
            foreach (Rect rect in layerRects)
            {
                GUIUtility.DrawRectangle(rect, Color.cyan, true, pixel);
            }

            GUILayout.EndScrollView();
            layersScrollRect = GUILayoutUtility.GetLastRect();

            //Begin Layer Overall Toolbar
            GUILayout.BeginHorizontal(layerOverallToolbarStyle, GUILayout.Height(20));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("+", GUILayout.Width(16), GUILayout.Height(16)))
            {
                if (isGUIButtonClick())
                {
                    frame.createNewLayer(sprite);
                }
            }
            if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(16)))
            {
                if (isGUIButtonClick())
                {
                    frame.deleteCurrentLayer(sprite);
                }
            }
            GUILayout.Button("a", GUILayout.Width(16), GUILayout.Height(16));
            GUILayout.Button("b", GUILayout.Width(16), GUILayout.Height(16));

            GUILayout.EndHorizontal();
            //End Layer Overall Toolbar

            GUILayout.EndVertical();
            layersOffsetRect = GUILayoutUtility.GetLastRect();
            //End GUI layoutting

            trackMouseClicksAndDrags();

            handleCursors();

            dragWindow();
        }