public override void OnInspectorGUI()
    {
        UPAImage img = (UPAImage)target;

        GUILayout.BeginArea(new Rect(5, 53, Screen.width - 10, Screen.height));

        if (GUILayout.Button("Open", GUILayout.Height(40)))
        {
            UPAEditorWindow.CurrentImg = UPASession.OpenImageByAsset(img);
            if (UPAEditorWindow.window != null)
            {
                UPAEditorWindow.window.Repaint();
            }
        }

        if (GUILayout.Button("Export", GUILayout.Height(40)))
        {
            UPAExportWindow.Init(img);
        }

        GUILayout.EndArea();

        //Make sure the textures are loaded
        img.LoadAllTexsFromMaps();

        float ratio = (float)img.width / (float)img.height;

        EditorGUI.DrawTextureTransparent(new Rect(5, 150, Screen.width - 10, (Screen.width - 10) * ratio), img.GetFinalImage(true), ScaleMode.ScaleToFit, 0);
    }
    public override void OnInspectorGUI()
    {
        UPAImage img = (UPAImage)target;

        GUILayout.BeginArea(new Rect(5, 53, Screen.width - 10, Screen.height));

        if (GUILayout.Button("Open", GUILayout.Height(40)))
        {
            UPAEditorWindow.CurrentImg = UPASession.OpenImageByAsset(img);
            if (UPAEditorWindow.window != null)
            {
                UPAEditorWindow.window.Repaint();
            }
        }

        if (GUILayout.Button("Export", GUILayout.Height(40)))
        {
            UPAExportWindow.Init(img);
        }

        GUILayout.EndArea();

        Texture2D preview = UPASession.PreviewImage(img);
        float     ratio   = preview.width / preview.height;

        EditorGUI.DrawTextureTransparent(new Rect(5, 150, Screen.width - 10, (Screen.width - 10) * ratio), preview, ScaleMode.ScaleToFit, 0);
        DestroyImmediate(preview);
        //UPADrawer.DrawImageInInspector ( img, new Rect (50,0, Screen.width, Screen.height) );
    }
예제 #3
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);
        }
    }
예제 #4
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);
        }
    }
예제 #5
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);
    }