public static void Init()
 {
     // Get existing open window or if none, make new one
     window = (UPAImageCreationWindow)EditorWindow.GetWindow (typeof (UPAImageCreationWindow));
     window.title = "New Image";
     window.position = new Rect(Screen.width/2 + 250/2f,Screen.height/2 - 80, 250, 105);
     window.ShowPopup();
 }
 public static void Init()
 {
     // Get existing open window or if none, make new one
     window          = (UPAImageCreationWindow)EditorWindow.GetWindow(typeof(UPAImageCreationWindow));
     window.title    = "New Image";
     window.position = new Rect(Screen.width / 2 + 250 / 2f, Screen.height / 2 - 80, 250, 105);
     window.ShowPopup();
 }
	public static void Init () {
		// Get existing open window or if none, make new one
		window = (UPAImageCreationWindow)EditorWindow.GetWindow (typeof (UPAImageCreationWindow));
		#if UNITY_4_3
		window.title = "New Image";
		#elif UNITY_4_6
		window.title = "New Image";
		#else
		window.titleContent = new GUIContent ("New Image");
		#endif
		window.position = new Rect(Screen.width/2 + 250/2f,Screen.height/2 - 80, 250, 105);
		window.ShowPopup();
	}
 public static void Init()
 {
     // Get existing open window or if none, make new one
     window = (UPAImageCreationWindow)EditorWindow.GetWindow(typeof(UPAImageCreationWindow));
             #if UNITY_4_3
     window.title = "New Image";
             #elif UNITY_4_6
     window.title = "New Image";
             #else
     window.titleContent = new GUIContent("New Image");
             #endif
     window.position = new Rect(Screen.width / 2 + 250 / 2f, Screen.height / 2 - 80, 250, 105);
     window.ShowPopup();
 }
Пример #5
0
    // Draw the settings toolbar
    public static void DrawToolbar(Rect window, Vector2 mousePos)
    {
        // Draw toolbar bg
        EditorGUI.DrawRect(new Rect(0, 0, window.width, 40), toolbarColor);

        if (GUI.Button(new Rect(5, 4, 50, 30), "New"))
        {
            UPAImageCreationWindow.Init();
        }
        if (GUI.Button(new Rect(60, 4, 50, 30), "Open"))
        {
            CurrentImg = UPASession.OpenImage();
            if (CurrentImg == null)
            {
                return;
            }
        }
        if (GUI.Button(new Rect(115, 4, 50, 30), "Export"))
        {
            UPAExportWindow.Init(CurrentImg);
        }

        if (GUI.Button(new Rect(179, 6, 25, 25), "+"))
        {
            CurrentImg.gridSpacing *= 1.2f;
        }
        if (GUI.Button(new Rect(209, 6, 25, 25), "-"))
        {
            CurrentImg.gridSpacing *= 0.8f;
            CurrentImg.gridSpacing -= 2;
        }

        CurrentImg.selectedColor = EditorGUI.ColorField(new Rect(250, 7, 70, 25), CurrentImg.selectedColor);
        EditorGUI.DrawRect(new Rect(303, 7, 20, 25), toolbarColor);
        //bgColor = EditorGUI.ColorField (new Rect (400, 4, 70, 25), bgColor);

        GUI.backgroundColor = Color.white;
        if (CurrentImg.tool == UPATool.PaintBrush)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(320, 4, 60, 30), "Paint"))
        {
            CurrentImg.tool = UPATool.PaintBrush;
        }
        GUI.backgroundColor = Color.white;
        if (CurrentImg.tool == UPATool.BoxBrush)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(450, 4, 60, 30), "Box Fill"))
        {
            EditorUtility.DisplayDialog(
                "In Development",
                "This feature is currently being developed.",
                "Get it done please");
            //tool = UPATool.BoxBrush;
        }
        GUI.backgroundColor = Color.white;
        if (CurrentImg.tool == UPATool.Eraser)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(385, 4, 60, 30), "Erase"))
        {
            CurrentImg.tool = UPATool.Eraser;
        }
        GUI.backgroundColor = Color.white;

        style.normal.textColor = new Color(0.7f, 0.7f, 0.7f);
        style.fontSize         = 12;
        style.fontStyle        = FontStyle.Normal;
        GUI.Label(new Rect(525, 11, 150, 30), "Use WASD to navigate.", style);

        if (GUI.Button(new Rect(684, 4, 55, 30), "Center"))
        {
            CurrentImg.gridOffsetX = 0;
            CurrentImg.gridOffsetY = 0;
        }

        CurrentImg.gridBGIndex = GUI.Toolbar(new Rect(743, 4, 130, 30), CurrentImg.gridBGIndex, gridBGStrings);

        if (CurrentImg.gridBGIndex == 0)
        {
            gridBGColor = Color.black;
        }
        else if (CurrentImg.gridBGIndex == 1)
        {
            gridBGColor = Color.white;
        }
        else
        {
            gridBGColor = Color.clear;
        }

        Vector2 pixelCoordinate = CurrentImg.GetReadablePixelCoordinate(mousePos);

        GUI.Label(new Rect(880, 11, 100, 30), "(" + (int)pixelCoordinate.x + "," + (int)pixelCoordinate.y + ")", style);

        if (CurrentImg.tool == UPATool.ColorPicker)
        {
            style.fontStyle = FontStyle.Bold;
            style.fontSize  = 15;
            GUI.Label(new Rect(window.width / 2f - 140, 60, 100, 30), "Click on a pixel to choose a color.", style);
        }
    }
Пример #6
0
    // Draw the Pixel Art Editor.
    // This includes both toolbar and painting area.
    // TODO: Add comments
    void OnGUI()
    {
        if (window == null)
        {
            Init();
        }

        if (CurrentImg == null)
        {
            string curImgPath = EditorPrefs.GetString("currentImgPath", "");

            if (curImgPath.Length != 0)
            {
                CurrentImg = UPASession.OpenImageAtPath(curImgPath);
                return;
            }

            if (GUI.Button(new Rect(window.position.width / 2f - 140, window.position.height / 2f - 25, 130, 50), "New Image"))
            {
                UPAImageCreationWindow.Init();
            }
            if (GUI.Button(new Rect(window.position.width / 2f + 10, window.position.height / 2f - 25, 130, 50), "Open Image"))
            {
                CurrentImg = UPASession.OpenImage();
                return;
            }

            return;
        }

        // Init the textures correctly, won't cost performance if nothing to load
        CurrentImg.LoadAllTexsFromMaps();

        EditorGUI.DrawRect(window.position, new Color32(30, 30, 30, 255));


        #region Event handling
        Event e = Event.current;                //Init event handler

        //Capture mouse position
        Vector2 mousePos = e.mousePosition;

        // If key is pressed
        if (e.button == 0)
        {
            // Mouse buttons
            if (e.isMouse && mousePos.y > 40 && e.type != EventType.mouseUp)
            {
                if (!UPADrawer.GetLayerPanelRect(window.position).Contains(mousePos))
                {
                    if (tool == UPATool.Eraser)
                    {
                        CurrentImg.SetPixelByPos(Color.clear, mousePos, CurrentImg.selectedLayer);
                    }
                    else if (tool == UPATool.PaintBrush)
                    {
                        CurrentImg.SetPixelByPos(selectedColor, mousePos, CurrentImg.selectedLayer);
                    }
                    else if (tool == UPATool.BoxBrush)
                    {
                        Debug.Log("TODO: Add Box Brush tool.");
                    }
                    else if (tool == UPATool.ColorPicker)
                    {
                        Vector2 pCoord   = CurrentImg.GetPixelCoordinate(mousePos);
                        Color?  newColor = CurrentImg.GetBlendedPixel((int)pCoord.x, (int)pCoord.y);
                        if (newColor != null && newColor != Color.clear)
                        {
                            selectedColor = (Color)newColor;
                        }
                        tool = lastTool;
                    }
                }
            }

            // Key down
            if (e.type == EventType.keyDown)
            {
                if (e.keyCode == KeyCode.W)
                {
                    gridOffsetY += 20f;
                }
                if (e.keyCode == KeyCode.S)
                {
                    gridOffsetY -= 20f;
                }
                if (e.keyCode == KeyCode.A)
                {
                    gridOffsetX += 20f;
                }
                if (e.keyCode == KeyCode.D)
                {
                    gridOffsetX -= 20f;
                }

                if (e.keyCode == KeyCode.Alpha1)
                {
                    tool = UPATool.PaintBrush;
                }
                if (e.keyCode == KeyCode.Alpha2)
                {
                    tool = UPATool.Eraser;
                }
                if (e.keyCode == KeyCode.P)
                {
                    lastTool = tool;
                    tool     = UPATool.ColorPicker;
                }

                if (e.keyCode == KeyCode.UpArrow)
                {
                    gridSpacing *= 1.2f;
                }
                if (e.keyCode == KeyCode.DownArrow)
                {
                    gridSpacing *= 0.8f;
                    gridSpacing -= 2;
                }
            }

            if (e.control)
            {
                if (lastTool == UPATool.Empty)
                {
                    lastTool = tool;
                    tool     = UPATool.Eraser;
                }
            }
            else if (e.type == EventType.keyUp && e.keyCode == KeyCode.LeftControl)
            {
                if (lastTool != UPATool.Empty)
                {
                    tool     = lastTool;
                    lastTool = UPATool.Empty;
                }
            }
        }

        // TODO: Better way of doing this?
        // Why does it behave so weirdly with my mac tablet.
        if (e.type == EventType.scrollWheel)
        {
            gridSpacing -= e.delta.y;
        }
        #endregion

        // DRAW IMAGE
        UPADrawer.DrawImage(CurrentImg);

        UPADrawer.DrawToolbar(window.position, mousePos);

        UPADrawer.DrawLayerPanel(window.position);

        e.Use();                // Release event handler
    }
Пример #7
0
    // Draw the Pixel Art Editor.
    // This includes both toolbar and painting area.
    // TODO: Add comments
    void OnGUI()
    {
        if (window == null)
        {
            Init();
        }

        if (CurrentImg == null || CurrentImg.map == null)
        {
            string curImgPath = EditorPrefs.GetString("currentImgPath", "");

            if (curImgPath.Length != 0)
            {
                CurrentImg = UPASession.OpenImageAtPath(curImgPath);
                return;
            }

            if (GUI.Button(new Rect(window.position.width / 2f - 140, window.position.height / 2f - 25, 130, 50), "New Image"))
            {
                UPAImageCreationWindow.Init();
            }
            if (GUI.Button(new Rect(window.position.width / 2f + 10, window.position.height / 2f - 25, 130, 50), "Open Image"))
            {
                CurrentImg = UPASession.OpenImage();
                return;
            }

            return;
        }

        bool updateRects = false;

        if (window.position != lastPos)
        {
            updateRects = true;
        }
        lastPos = window.position;

        EditorGUI.DrawRect(window.position, new Color32(30, 30, 30, 255));


        #region Event handling
        Event e = Event.current;                //Init event handler

        // If key is pressed
        if (e.button == 0)
        {
            // Mouse buttons
            if (e.isMouse && e.mousePosition.y > 40)
            {
                if (tool == UPATool.Eraser)
                {
                    CurrentImg.ColorPixel(Color.clear, e.mousePosition);
                }
                else if (tool == UPATool.PaintBrush)
                {
                    CurrentImg.ColorPixel(selectedColor, e.mousePosition);
                }
                else if (tool == UPATool.BoxBrush)
                {
                    Debug.Log("TODO: Add Box Brush tool.");
                }
            }

            // Key down
            if (e.type == EventType.keyDown)
            {
                if (e.keyCode == KeyCode.W)
                {
                    gridOffsetY += 20f;
                    updateRects  = true;
                }
                if (e.keyCode == KeyCode.S)
                {
                    gridOffsetY -= 20f;
                    updateRects  = true;
                }
                if (e.keyCode == KeyCode.A)
                {
                    gridOffsetX += 20f;
                    updateRects  = true;
                }
                if (e.keyCode == KeyCode.D)
                {
                    gridOffsetX -= 20f;
                    updateRects  = true;
                }

                if (e.keyCode == KeyCode.Alpha1)
                {
                    tool = UPATool.PaintBrush;
                }
                if (e.keyCode == KeyCode.Alpha2)
                {
                    tool = UPATool.Eraser;
                }

                if (e.keyCode == KeyCode.UpArrow)
                {
                    gridSpacing *= 1.2f;
                }
                if (e.keyCode == KeyCode.DownArrow)
                {
                    gridSpacing *= 0.8f;
                }
            }

            if (e.control)
            {
                if (lastTool == UPATool.Empty)
                {
                    lastTool = tool;
                    tool     = UPATool.Eraser;
                }
            }
            else
            {
                if (lastTool != UPATool.Empty)
                {
                    tool     = lastTool;
                    lastTool = UPATool.Empty;
                }
            }
        }

        // TODO: Better way of doing this?
        // Why does it behave so weirdly with my mac tablet.
        if (e.type == EventType.scrollWheel)
        {
            gridSpacing -= e.delta.y;
        }
        #endregion

        EditorGUI.DrawRect(CurrentImg.FillRect(), UPADrawer.gridBGColor);

        // DRAW IMAGE
        if (UPADrawer.DrawImage(CurrentImg, window.position))
        {
            updateRects = true;
        }

        if (UPADrawer.DrawToolbar(window.position))
        {
            updateRects = true;
        }

        if (GUI.changed)
        {
            updateRects = true;
        }

        if (updateRects)
        {
            if (CurrentImg != null)
            {
                CurrentImg.UpdateRects();
            }
        }

        e.Use();                // Release event handler
    }
Пример #8
0
    // Draw the Pixel Art Editor.
    // This includes both toolbar and painting area.
    // TODO: Add comments
    void OnGUI()
    {
        if (window == null)
        {
            Init();
        }

        if (CurrentImg == null || TemplateImage == null)
        {
            Debug.Log("one is null");

            string curImgPath      = EditorPrefs.GetString("currentAnimationPath", "");
            string templateImgPath = EditorPrefs.GetString("templateImgPath", "");



            if (curImgPath.Length != 0)
            {
                animation = UPASession.OpenAnimationsFromFolder(false, curImgPath);

                if (animation.Count > 0)
                {
                    CurrentImg = animation[0];
                    //CurrentImg.initilizeAlphas();
                    animationIndex = 0;
                }
            }

            if (templateImgPath.Length != 0)
            {
                TemplateImage = UPASession.OpenImageAtPath(templateImgPath, true);
                TemplateImage.initilizeAlphas();
                TemplateImage.loopThroughImage();
            }

            if (CurrentImg == null)
            {
                if (GUI.Button(new Rect(window.position.width / 2f - 140, window.position.height / 2f - 25, 130, 50), "Load Animation"))
                {
                    //UPASession.OpenImage();
                    animation = UPASession.OpenAnimationsFromFolder(false);
                    CurrentImg.initilizeAlphas();
                    animationIndex = 0;
                }
            }
            else if (TemplateImage == null)
            {
                if (GUI.Button(new Rect(window.position.width / 2f - 140, window.position.height / 2f - 25, 130, 50), "New Template"))
                {
                    UPAImageCreationWindow.Init();
                }
                if (GUI.Button(new Rect(window.position.width / 2f + 10, window.position.height / 2f - 25, 130, 50), "Open Template"))
                {
                    TemplateImage = UPASession.OpenFolder(true);
                    TemplateImage.LoadAllTexsFromMaps();
                    TemplateImage.initilizeAlphas();
                    TemplateImage.loopThroughImage();
                    return;
                }
            }



            return;
        }

        if (gettingPreviewArmor)
        {
            if (GUI.Button(new Rect(window.position.width / 2f, window.position.height / 8f, 130, 50), "Load Head"))
            {
                pathDictionary["head"] = EditorUtility.OpenFolderPanel(
                    "Choose Animation Folder",
                    "Assets/Sprites/Armor/Heads/",
                    "");
            }

            if (GUI.Button(new Rect(window.position.width / 2f - 70, window.position.height / 8f + 60, 130, 50), "Load Arms"))
            {
                pathDictionary["arms"] = EditorUtility.OpenFolderPanel(
                    "Choose Animation Folder",
                    "Assets/Sprites/Armor/Arms/",
                    "");
            }

            if (GUI.Button(new Rect(window.position.width / 2f + 70, window.position.height / 8f + 60, 130, 50), "Load Body"))
            {
                pathDictionary["body"] = EditorUtility.OpenFolderPanel(
                    "Choose Animation Folder",
                    "Assets/Sprites/Armor/Bodies/",
                    "");
            }

            if (GUI.Button(new Rect(window.position.width / 2f, window.position.height / 8f + 120, 130, 50), "Load Legs"))
            {
                pathDictionary["legs"] = EditorUtility.OpenFolderPanel(
                    "Choose Animation Folder",
                    "Assets/Sprites/Legs/",
                    "");
            }

            if (GUI.Button(new Rect(window.position.width / 2f + 10, window.position.height / 2f - 25, 130, 50), "Done"))
            {
                UPAImage armorTemplate = UPASession.LoadImageTemplate(pathDictionary);

                //now we have a map to draw things from lets now map the template to each proper layer

                List <UPAImage> newAnimation = new List <UPAImage>();

                foreach (UPAImage img in animation)
                {
                    UPAImage newImage = UPASession.CreateUPAImage(img.width, img.height);

                    for (int i = 0; i < img.layers.Count; i++)
                    {
                        UPALayer layer = new UPALayer(img.layers[i]);



                        UPALayer templateLayer = armorTemplate.GetLayer(layer.name);

                        if (templateLayer != null)
                        {
                            Debug.Log("layer does not == null!");



                            foreach (Vector2 key in layer.colorMapDictionary.Keys)
                            {
                                Vector2 value = layer.colorMapDictionary[key];
                                layer.SetPixel((int)key.x, (int)key.y, templateLayer.GetPixel((int)value.x, (int)value.y));
                            }
                        }

                        if (i != 0)
                        {
                            newImage.AddLayer();
                        }

                        newImage.layers[i] = layer;
                    }

                    newAnimation.Add(newImage);
                }

                animation = newAnimation;

                gettingPreviewArmor = false;
                pathDictionary.Clear();
            }

            return;
        }



        // Init the textures correctly, won't cost performance if nothing to load
        CurrentImg.LoadAllTexsFromMaps();

        TemplateImage.LoadAllTexsFromMaps();

        EditorGUI.DrawRect(window.position, new Color32(30, 30, 30, 255));


        #region Event handling
        Event e = Event.current;                //Init event handler

        //Capture mouse position
        Vector2 mousePos = e.mousePosition;

        // If key is pressed
        if (e.button == 0)
        {
            // Mouse buttons
            if (e.isMouse && mousePos.y > 40 && e.type != EventType.MouseUp)
            {
                if (!UPADrawer.GetLayerPanelRect(window.position).Contains(mousePos))
                {
                    if (selectedTool == UPATool.Eraser)
                    {
                        CurrentImg.SetPixelByPos(Color.clear, mousePos, CurrentImg.selectedLayer);
                    }
                    else if (selectedTool == UPATool.PaintBrush)
                    {
                        CurrentImg.SetPixelByPos(selectedColor, mousePos, CurrentImg.selectedLayer);
                    }
                    else if (selectedTool == UPATool.BoxBrush)
                    {
                        Debug.Log("TODO: Add Box Brush tool.");
                    }
                    else if (selectedTool == UPATool.ColorPicker)
                    {
                        Vector2 pCoord   = CurrentImg.GetPixelCoordinate(mousePos);
                        Color?  newColor = CurrentImg.GetBlendedPixel((int)pCoord.x, (int)pCoord.y);
                        if (newColor != null && newColor != Color.clear)
                        {
                            selectedColor = (Color)newColor;
                        }
                        selectedTool = lastTool;
                    }
                    else if (selectedTool == UPATool.Map)
                    {
                        CurrentImg.mapPixelByPos(mousePos, TemplateImage.currentPixelPosition);
                    }
                }
            }

            // Key down
            if (e.type == EventType.KeyDown)
            {
                if (e.keyCode == KeyCode.W)
                {
                    changeLayer(1);
                }
                if (e.keyCode == KeyCode.S)
                {
                    changeLayer(-1);
                }
                if (e.keyCode == KeyCode.A)
                {
                    TemplateImage.focusPixel(-1);
                }
                if (e.keyCode == KeyCode.D)
                {
                    TemplateImage.focusPixel(1);
                }

                if (e.keyCode == KeyCode.Alpha1)
                {
                    selectedTool = UPATool.PaintBrush;
                }
                if (e.keyCode == KeyCode.Alpha2)
                {
                    selectedTool = UPATool.Eraser;
                }
                if (e.keyCode == KeyCode.P)
                {
                    lastTool     = selectedTool;
                    selectedTool = UPATool.ColorPicker;
                }

                if (e.keyCode == KeyCode.UpArrow)
                {
                    CurrentImg.layers[0].setAlpha(true);
                }
                if (e.keyCode == KeyCode.DownArrow)
                {
                    CurrentImg.layers[0].setAlpha(false);
                }
                if (e.keyCode == KeyCode.LeftArrow)
                {
                    changeFrame(-1);
                }
                if (e.keyCode == KeyCode.RightArrow)
                {
                    changeFrame(1);
                }
            }

            if (e.control)
            {
                if (lastTool == UPATool.Empty)
                {
                    lastTool     = selectedTool;
                    selectedTool = UPATool.Eraser;
                }
            }
            else if (e.type == EventType.KeyUp && e.keyCode == KeyCode.LeftControl)
            {
                if (lastTool != UPATool.Empty)
                {
                    selectedTool = lastTool;
                    lastTool     = UPATool.Empty;
                }
            }
        }



        // TODO: Better way of doing this?
        // Why does it behave so weirdly with my mac tablet.
        if (e.type == EventType.ScrollWheel)
        {
            gridSpacing -= e.delta.y;
        }
        #endregion

        // DRAW IMAGE
        UPADrawer.DrawImage(CurrentImg, false);

        //Test draw another image
        UPADrawer.DrawImage(TemplateImage, true);

        UPADrawer.DrawToolbar(window.position, mousePos);

        UPADrawer.DrawLayerPanel(window.position);

        UPADrawer.DrawFramePanel(window.position);

        e.Use();                // Release event handler
    }
Пример #9
0
    // Draw the settings toolbar
    public static void DrawToolbar(Rect window, Vector2 mousePos)
    {
        // Draw toolbar bg
        EditorGUI.DrawRect(new Rect(0, 0, window.width, 40), toolbarColor);

        if (GUI.Button(new Rect(5, 4, 50, 30), "New"))
        {
            UPAImageCreationWindow.Init();
        }
        if (GUI.Button(new Rect(60, 4, 50, 30), "Open"))
        {
            //CurrentImg = UPASession.OpenFolder(false);
            CurrentImg = UPASession.OpenImage();

            CurrentImg.initilizeAlphas();
            if (CurrentImg == null)
            {
                return;
            }
        }
        if (GUI.Button(new Rect(115, 4, 50, 30), "Export"))
        {
            UPAExportWindow.Init(CurrentImg);
        }

        if (GUI.Button(new Rect(179, 6, 25, 25), "+"))
        {
            CurrentImg.gridSpacing *= 1.2f;
        }
        if (GUI.Button(new Rect(209, 6, 25, 25), "-"))
        {
            CurrentImg.gridSpacing *= 0.8f;
            CurrentImg.gridSpacing -= 2;
        }

        CurrentImg.selectedColor = EditorGUI.ColorField(new Rect(250, 7, 70, 25), CurrentImg.selectedColor);
        EditorGUI.DrawRect(new Rect(303, 7, 20, 25), toolbarColor);
        //bgColor = EditorGUI.ColorField (new Rect (400, 4, 70, 25), bgColor);

        GUI.backgroundColor = Color.white;
        if (UPAEditorWindow.selectedTool == UPATool.PaintBrush)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(320, 4, 60, 30), "Paint"))
        {
            UPAEditorWindow.selectedTool = UPATool.PaintBrush;
        }
        GUI.backgroundColor = Color.white;
        if (UPAEditorWindow.selectedTool == UPATool.Map)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(450, 4, 60, 30), "Map"))
        {
            UPAEditorWindow.selectedTool = UPATool.Map;
        }
        GUI.backgroundColor = Color.white;
        if (UPAEditorWindow.selectedTool == UPATool.Eraser)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(385, 4, 60, 30), "Erase"))
        {
            UPAEditorWindow.selectedTool = UPATool.Eraser;
        }
        GUI.backgroundColor = Color.white;

        style.normal.textColor = new Color(0.7f, 0.7f, 0.7f);
        style.fontSize         = 12;
        style.fontStyle        = FontStyle.Normal;
        GUI.Label(new Rect(525, 11, 150, 30), "Use WASD to navigate.", style);

        if (GUI.Button(new Rect(684, 4, 55, 30), "Center"))
        {
            CurrentImg.gridOffsetX = 0;
            CurrentImg.gridOffsetY = 0;
        }

        CurrentImg.gridBGIndex = GUI.Toolbar(new Rect(743, 4, 130, 30), CurrentImg.gridBGIndex, gridBGStrings);

        if (CurrentImg.gridBGIndex == 0)
        {
            gridBGColor = Color.black;
        }
        else if (CurrentImg.gridBGIndex == 1)
        {
            gridBGColor = Color.white;
        }
        else
        {
            gridBGColor = Color.clear;
        }

        if (GUI.Button(new Rect(930, 4, 75, 30), "Save Armor"))
        {
            Armor armor = new Armor("shoulder");
            armor.AddArmorPiece(new ArmorPiece("topSide"));

            armorSavePath = DataController.SaveArmor(armor);

            Debug.Log(armorSavePath);
        }

        if (GUI.Button(new Rect(1010, 4, 75, 30), "Load Armor"))
        {
            Armor armor = DataController.LoadArmor(armorSavePath);

            Debug.Log("armor found");
            Debug.Log(armor.name);

            for (int i = 0; i < armor.armorPieces.Count; i++)
            {
                Debug.Log(armor.armorPieces[i].name);
            }
        }

        if (GUI.Button(new Rect(1090, 4, 75, 30), "Load template"))
        {
            Debug.Log("load template pressed");
            UPAImage img = UPASession.OpenFolder(true);

            img.initilizeAlphas();
            img.loopThroughImage();
        }

        if (GUI.Button(new Rect(1175, 4, 100, 30), "Load Animations"))
        {
            UPAEditorWindow.animation = UPASession.OpenAnimationsFromFolder(false);
        }

        if (GUI.Button(new Rect(1295, 4, 100, 30), "Preview"))
        {
            UPAEditorWindow.gettingPreviewArmor = true;
        }

        if (GUI.Button(new Rect(1410, 4, 100, 30), "Save Anim"))
        {
            UPAAnimator.MakeAnimationClip(UPAEditorWindow.animation);
        }

        //Vector2 pixelCoordinate = CurrentImg.GetReadablePixelCoordinate(mousePos);
        //CurrentImg.GetPixelByPos(pixelCoordinate, CurrentImg.selectedLayer);
        //GUI.Label(new Rect(1200, 11, 200, 30), "(" + CurrentImg.GetPixelByPos(mousePos, CurrentImg.selectedLayer, true) + ")", style);
        //GUI.Label(new Rect(880, 11, 100, 30), "(" + (int)pixelCoordinate.x + "," + (int)pixelCoordinate.y + ")", style);

        if (CurrentImg.tool == UPATool.ColorPicker)
        {
            style.fontStyle = FontStyle.Bold;
            style.fontSize  = 15;
            GUI.Label(new Rect(window.width / 2f - 140, 60, 100, 30), "Click on a pixel to choose a color.", style);
        }
    }
Пример #10
0
    // Draw the settings toolbar
    // Return true if image rects need to be updated.
    public static bool DrawToolbar(Rect window)
    {
        bool updateRects = false;

        // Draw toolbar bg
        EditorGUI.DrawRect(new Rect(0, 0, window.width, 40), toolbarColor);

        if (GUI.Button(new Rect(5, 4, 50, 30), "New"))
        {
            UPAImageCreationWindow.Init();
        }
        if (GUI.Button(new Rect(60, 4, 50, 30), "Open"))
        {
            CurrentImg = UPASession.OpenImage();
            if (CurrentImg == null)
            {
                return(false);
            }
        }
        if (GUI.Button(new Rect(115, 4, 50, 30), "Export"))
        {
            UPAExportWindow.Init(CurrentImg);
        }

        if (GUI.Button(new Rect(179, 6, 25, 25), "+"))
        {
            CurrentImg.gridSpacing *= 1.5f;
            updateRects             = true;
        }
        if (GUI.Button(new Rect(209, 6, 25, 25), "-"))
        {
            CurrentImg.gridSpacing *= 0.5f;
            updateRects             = true;
        }

        CurrentImg.selectedColor = EditorGUI.ColorField(new Rect(250, 7, 70, 25), CurrentImg.selectedColor);
        EditorGUI.DrawRect(new Rect(303, 7, 20, 25), toolbarColor);
        //bgColor = EditorGUI.ColorField (new Rect (400, 4, 70, 25), bgColor);

        GUI.backgroundColor = Color.white;
        if (CurrentImg.tool == UPATool.PaintBrush)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(320, 4, 60, 30), "Paint"))
        {
            CurrentImg.tool = UPATool.PaintBrush;
        }
        GUI.backgroundColor = Color.white;
        if (CurrentImg.tool == UPATool.BoxBrush)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(450, 4, 60, 30), "Box Fill"))
        {
            EditorUtility.DisplayDialog(
                "In Development",
                "This feature is currently being developed.",
                "Get it done please");
            //tool = UPATool.BoxBrush;
        }
        GUI.backgroundColor = Color.white;
        if (CurrentImg.tool == UPATool.Eraser)
        {
            GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(385, 4, 60, 30), "Erase"))
        {
            CurrentImg.tool = UPATool.Eraser;
        }
        GUI.backgroundColor = Color.white;

        style.normal.textColor = new Color(0.7f, 0.7f, 0.7f);
        GUI.Label(new Rect(525, 11, 150, 30), "Use WASD to navigate.", style);

        if (GUI.Button(new Rect(670, 4, 80, 30), "Center View"))
        {
            CurrentImg.gridOffsetX = 0;
            CurrentImg.gridOffsetY = 0;
        }

        CurrentImg.gridBGIndex = GUI.Toolbar(new Rect(760, 4, 90, 30), CurrentImg.gridBGIndex, gridBGStrings);

        if (CurrentImg.gridBGIndex == 0)
        {
            gridBGColor = Color.black;
        }
        else
        {
            gridBGColor = Color.white;
        }

        return(updateRects);
    }