コード例 #1
0
    public static void DrawFramePanel(Rect window)
    {
        style.imagePosition = ImagePosition.ImageAbove;

        if (CurrentImg == null || UPAEditorWindow.animation == null)
        {
            return;
        }

        for (int i = 0; i < UPAEditorWindow.animation.Count; i++)
        {
            GUI.backgroundColor = Color.white;
            if (i == UPAEditorWindow.animationIndex)
            {
                GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
            }

            UPALayer tempLayer = CurrentImg.layers[i];
            if (GUI.Button(new Rect(820 + i * 70, window.height - 45, 65, 33), ""))
            {
                UPAEditorWindow.animationIndex = i;
                CurrentImg = UPAEditorWindow.animation[i];
            }

            GUI.backgroundColor = Color.white;
            GUI.Label(new Rect(830 + i * 70, window.height - 40, 90, 30), "" + (i + 1));
        }
    }
コード例 #2
0
    public void AddLayer()
    {
        Undo.RecordObject(this, "AddLayer");
        EditorUtility.SetDirty(this);
        this.dirty = true;

        UPALayer newLayer = new UPALayer(this);

        layers.Add(newLayer);
    }
コード例 #3
0
ファイル: UPAImage.cs プロジェクト: Alexander144/GamejamHamar
	// This is not called in constructor to have more control
	public void Init (int w, int h) {
		width = w;
		height = h;

		layers = new List<UPALayer>();
		UPALayer newLayer = new UPALayer (this);
		layers.Add ( newLayer );
		
		EditorUtility.SetDirty (this);
		dirty = true;
	}
コード例 #4
0
		public static Texture2D Blend (Texture2D lowerLayer, float lowerOpacity, Texture2D upperLayer, float upperOpacity, UPALayer.BlendMode mode) {
			switch (mode) {
			case UPALayer.BlendMode.NORMAL:
				return Normal(lowerLayer, lowerOpacity, upperLayer, upperOpacity);
			case UPALayer.BlendMode.MULTIPLY:
				return Multiply(lowerLayer, lowerOpacity, upperLayer, upperOpacity);
			case UPALayer.BlendMode.SCREEN:
				return Screen(lowerLayer, lowerOpacity, upperLayer, upperOpacity);
			default:
				return Normal(lowerLayer, lowerOpacity, upperLayer, upperOpacity);
			}

		}
コード例 #5
0
    // This is not called in constructor to have more control
    public void Init(int w, int h)
    {
        width  = w;
        height = h;

        layers = new List <UPALayer>();
        UPALayer newLayer = new UPALayer(this);

        layers.Add(newLayer);

        EditorUtility.SetDirty(this);
        dirty = true;
    }
コード例 #6
0
    public void ChangeLayerPosition(int from, int to)
    {
        if (from >= layers.Count || to >= layers.Count || from < 0 || to < 0)
        {
            Debug.LogError("Cannot ChangeLayerPosition, out of range.");
            return;
        }

        UPALayer layer = layers[from];

        layers.RemoveAt(from);
        layers.Insert(to, layer);

        dirty = true;
    }
コード例 #7
0
	public static void Init (UPALayer layer) {
		// Get existing open window or if none, make new one
		window = (UPALayerSettings)EditorWindow.GetWindow (typeof (UPALayerSettings));
		#if UNITY_4_3
		window.title = layer.name + " - Settings";
		#elif UNITY_4_6
		window.title = layer.name + " - Settings";
		#else
		window.titleContent = new GUIContent (layer.name + " - Settings");
		#endif
		
		window.position = new Rect(Screen.width/2 + 260/2f,Screen.height/2 - 80, 360, 170);
		window.ShowPopup();
		
		window.layer = layer;
	}
コード例 #8
0
    public static void Init(UPALayer layer)
    {
        // Get existing open window or if none, make new one
        window = (UPALayerSettings)EditorWindow.GetWindow(typeof(UPALayerSettings));
                #if UNITY_4_3
        window.title = layer.name + " - Settings";
                #elif UNITY_4_6
        window.title = layer.name + " - Settings";
                #else
        window.titleContent = new GUIContent(layer.name + " - Settings");
                #endif

        window.position = new Rect(Screen.width / 2 + 260 / 2f, Screen.height / 2 - 80, 360, 170);
        window.ShowPopup();

        window.layer = layer;
    }
コード例 #9
0
ファイル: UPALayer.cs プロジェクト: Jordan-Mark/BlackoutGame
	// Create clone of other UPALayer
	public UPALayer(UPALayer original) {
		name = original.name + " - Clone";
		opacity = 1;
		mode = original.mode;

		map = (Color[]) original.map.Clone();
		tex = new Texture2D (original.parentImg.width, original.parentImg.height);
		tex.SetPixels (original.tex.GetPixels ());

		tex.filterMode = FilterMode.Point;
		tex.Apply ();
		
		enabled = true;
		locked = original.locked;
		parentImg = original.parentImg;

		// Because Unity won't record map (Color[]) as an undo,
		// we instead register a callback to LoadMapFromTex since undoing textures works fine
		Undo.undoRedoPerformed += LoadMapFromTex; // subscribe to the undo event
	}
コード例 #10
0
    // Create clone of other UPALayer
    public UPALayer(UPALayer original)
    {
        name    = original.name + " - Clone";
        opacity = 1;
        mode    = original.mode;

        map = (Color[])original.map.Clone();
        tex = new Texture2D(original.parentImg.width, original.parentImg.height);
        tex.SetPixels(original.tex.GetPixels());

        tex.filterMode = FilterMode.Point;
        tex.Apply();

        enabled   = true;
        locked    = original.locked;
        parentImg = original.parentImg;

        // Because Unity won't record map (Color[]) as an undo,
        // we instead register a callback to LoadMapFromTex since undoing textures works fine
        Undo.undoRedoPerformed += LoadMapFromTex;         // subscribe to the undo event
    }
コード例 #11
0
    // Create clone of other UPALayer
    public UPALayer(UPALayer original)
    {
        name    = original.name;
        opacity = 1;
        mode    = original.mode;

        map = (Color[])original.map.Clone();
        tex = new Texture2D(original.parentImg.width, original.parentImg.height);

        Texture2D parentTex = original.tex;

        if (parentTex != null)
        {
            //TODO: may be bad to turn this off
            tex.SetPixels(original.tex.GetPixels());
        }
        else
        {
            Debug.LogError("no parent tex!!");
        }

        tex.filterMode = FilterMode.Point;
        tex.Apply();

        enabled   = true;
        locked    = original.locked;
        parentImg = original.parentImg;

        colorMapDictionary = original.colorMapDictionary;



        // Because Unity won't record map (Color[]) as an undo,
        // we instead register a callback to LoadMapFromTex since undoing textures works fine
        Undo.undoRedoPerformed += LoadMapFromTex;         // subscribe to the undo event
    }
コード例 #12
0
ファイル: UPADrawer.cs プロジェクト: Dannyrod00/rogue-DRod
    public static void DrawLayerPanel(Rect window)
    {
        style.imagePosition = ImagePosition.ImageAbove;

        int from = 0;
        int to   = 0;

        if (CurrentImg == null)
        {
            return;
        }

        for (int i = 0; i < CurrentImg.layers.Count; i++)
        {
            GUI.backgroundColor = Color.white;
            if (i == CurrentImg.selectedLayer)
            {
                GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
            }

            UPALayer tempLayer = CurrentImg.layers[i];
            if (GUI.Button(new Rect(12, window.height - 60 - i * 36, 65, 33), ""))
            {
                CurrentImg.selectedLayer = i;
            }

            GUI.backgroundColor = Color.white;
            GUI.Label(new Rect(15, window.height - 52 - i * 36, 90, 30), tempLayer.name);

            bool layerEnabled = tempLayer.enabled;
            tempLayer.enabled = GUI.Toggle(new Rect(80, window.height - 61 - i * 36, 15, 15), tempLayer.enabled, "");
            if (tempLayer.enabled != layerEnabled)
            {
                tempLayer.parentImg.dirty = true;
            }

            if (removeLayerIcon == null)
            {
                removeLayerIcon = (Texture2D)Resources.Load("UI/CrossWhite");
            }

            if (tempLayer.locked)
            {
                if (GUI.Button(new Rect(80, window.height - 43 - i * 36, 15, 15), Resources.Load("UI/locked") as Texture2D, style))
                {
                    tempLayer.locked = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(80, window.height - 43 - i * 36, 15, 15), Resources.Load("UI/unlocked") as Texture2D, style))
                {
                    tempLayer.locked = true;
                }
            }


            if (i + 1 < CurrentImg.layers.Count)
            {
                if (GUI.Button(new Rect(97, window.height - 60 - i * 36, 22, 16), "+"))
                {
                    from = i;
                    to   = i + 1;
                }
            }

            if (i > 0)
            {
                if (GUI.Button(new Rect(97, window.height - 44 - i * 36, 22, 16), "-"))
                {
                    from = i;
                    to   = i - 1;
                }
            }

            CurrentImg.layers[i] = tempLayer;
        }

        if (from != 0 || to != 0)
        {
            CurrentImg.ChangeLayerPosition(from, to);
        }

        GUIStyle smallButon = new GUIStyle();

        smallButon.fontSize          = 8;
        smallButon.alignment         = TextAnchor.MiddleCenter;
        smallButon.normal.background = Resources.Load("Background") as Texture2D;

        if (GUI.Button(new Rect(12, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/add") as Texture, "Add Layer"), smallButon))
        {
            CurrentImg.AddLayer();
        }

        if (CurrentImg.layerCount == 1)
        {
            GUI.contentColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(12 + 20, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/delete") as Texture, "Delete Layer"), smallButon))
        {
            if (CurrentImg.layers.Count > 1)
            {
                bool delete = EditorUtility.DisplayDialog(
                    "Delete Layer",
                    "Do you want to remove " + CurrentImg.layers[CurrentImg.selectedLayer].name + "?",
                    "Delete",
                    "Cancel");

                if (delete)
                {
                    CurrentImg.RemoveLayerAt(CurrentImg.selectedLayer);
                }
            }
        }
        GUI.contentColor = Color.white;

        if (GUI.Button(new Rect(12 + 20 * 2, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/import") as Texture, "Import Image"), smallButon))
        {
            string path = EditorUtility.OpenFilePanel(
                "Find an Image (.jpg | .png)",
                "/",
                "Image Files;*.jpg;*.png");

            if (path.Length != 0)
            {
                // Load Texture from file
                Texture2D tex = null;
                byte[]    fileData;
                if (File.Exists(path))
                {
                    fileData = File.ReadAllBytes(path);
                    tex      = new Texture2D(2, 2);
                    tex.LoadImage(fileData);                     //..this will auto-resize the texture dimensions.
                }
                // Create a new Image with textures dimensions
                CurrentImg.AddLayer();
                // Set pixel colors
                UPALayer layer = CurrentImg.layers[CurrentImg.layers.Count - 1];
                for (int x = 0; x < CurrentImg.width; x++)
                {
                    for (int y = 0; y < CurrentImg.height; y++)
                    {
                        layer.map[x + y * CurrentImg.width] = tex.GetPixel(x, CurrentImg.height - 1 - y);
                    }
                }
                layer.LoadTexFromMap();
            }
        }

        if (GUI.Button(new Rect(12 + 20 * 3, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/duplicate") as Texture, "Duplicate Layer"), smallButon))
        {
            CurrentImg.layers.Add(new UPALayer(CurrentImg.layers[CurrentImg.selectedLayer]));
        }

        if (CurrentImg.selectedLayer == 0)
        {
            GUI.contentColor = new Color(0.7f, 0.7f, 0.7f);
        }
        if (GUI.Button(new Rect(12 + 20 * 4, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/merge") as Texture, "Merge Layer Down"), smallButon))
        {
            if (CurrentImg.selectedLayer > 0)
            {
                UPALayer upper = CurrentImg.layers[CurrentImg.selectedLayer];
                UPALayer lower = CurrentImg.layers[CurrentImg.selectedLayer - 1];
                lower.tex = UPABlendModes.Blend(lower.tex, lower.opacity, upper.tex, upper.opacity, upper.mode);
                for (int x = 0; x < lower.tex.width; x++)
                {
                    for (int y = 0; y < lower.tex.height; y++)
                    {
                        lower.map[x + y * lower.tex.width] = lower.tex.GetPixel(x, lower.tex.height - 1 - y);
                    }
                }
                CurrentImg.RemoveLayerAt(CurrentImg.selectedLayer);
            }
        }
        GUI.contentColor = Color.white;

        //if (GUI.Button (new Rect (12 + 18 * 4, window.height - 18, 16, 16),  Resources.Load("UI/up") as Texture2D, style)) {
        //	CurrentImg.AddLayer ();
        //}

        //if (GUI.Button (new Rect (12 + 18 * 5, window.height - 18, 16, 16),  Resources.Load("UI/down") as Texture2D, style)) {
        //	CurrentImg.AddLayer ();
        //}

        if (GUI.Button(new Rect(12 + 20 * 5, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/edit") as Texture, "Layer Options"), smallButon))
        {
            UPALayerSettings.Init(CurrentImg.layers[CurrentImg.selectedLayer]);
        }

        // Draw layer button tooltips
        if (GUI.tooltip != "")
        {
            GUI.Box(new Rect(12, window.height - 43, 120, 20), GUI.tooltip);
        }

        //CurrentImg.selectedLayer = GUI.Toolbar (new Rect (4, window.height - 200, 90, 30), CurrentImg.selectedLayer, layerNames);
    }
コード例 #13
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
    }
コード例 #14
0
    public static void DrawLayerPanel(Rect window)
    {
        style.imagePosition = ImagePosition.ImageAbove;

        int from = 0;
        int to   = 0;

        for (int i = 0; i < CurrentImg.layers.Count; i++)
        {
            GUI.backgroundColor = Color.white;
            if (i == CurrentImg.selectedLayer)
            {
                GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
            }

            UPALayer tempLayer = CurrentImg.layers[i];
            if (GUI.Button(new Rect(12, window.height - 40 - i * 36, 65, 33), ""))
            {
                CurrentImg.selectedLayer = i;
            }
            GUI.backgroundColor = Color.white;
            GUI.Label(new Rect(15, window.height - 32 - i * 36, 90, 30), tempLayer.name);

            bool layerEnabled = tempLayer.enabled;
            tempLayer.enabled = GUI.Toggle(new Rect(80, window.height - 41 - i * 36, 15, 15), tempLayer.enabled, "");
            if (tempLayer.enabled != layerEnabled)
            {
                tempLayer.parentImg.dirty = true;
            }

            if (removeLayerIcon == null)
            {
                removeLayerIcon = (Texture2D)Resources.Load("UI/CrossWhite");
            }

            if (GUI.Button(new Rect(80, window.height - 23 - i * 36, 15, 15), removeLayerIcon, style))
            {
                if (CurrentImg.layers.Count > 1)
                {
                    bool delete = EditorUtility.DisplayDialog(
                        "Delete Layer",
                        "Do you want to remove " + CurrentImg.layers[i].name + "?",
                        "Delete",
                        "Cancel");

                    if (delete)
                    {
                        CurrentImg.RemoveLayerAt(i);
                        continue;
                    }
                }
            }

            if (i + 1 < CurrentImg.layers.Count)
            {
                if (GUI.Button(new Rect(97, window.height - 40 - i * 36, 22, 16), "+"))
                {
                    from = i;
                    to   = i + 1;
                }
            }

            if (i > 0)
            {
                if (GUI.Button(new Rect(97, window.height - 24 - i * 36, 22, 16), "-"))
                {
                    from = i;
                    to   = i - 1;
                }
            }

            CurrentImg.layers[i] = tempLayer;
        }

        if (from != 0 || to != 0)
        {
            CurrentImg.ChangeLayerPosition(from, to);
        }

        if (GUI.Button(new Rect(12, window.height - 32 - CurrentImg.layers.Count * 36, 85, 25), "New Layer"))
        {
            CurrentImg.AddLayer();
        }

        //CurrentImg.selectedLayer = GUI.Toolbar (new Rect (4, window.height - 200, 90, 30), CurrentImg.selectedLayer, layerNames);
    }
コード例 #15
0
ファイル: UPAImage.cs プロジェクト: Alexander144/GamejamHamar
	public void AddLayer () {
		Undo.RecordObject (this, "AddLayer");
		EditorUtility.SetDirty (this);
		this.dirty = true;

		UPALayer newLayer = new UPALayer (this);
		layers.Add(newLayer);
	}