Пример #1
0
        /// ======================================================================================================================================================================
        /// <summary>
        /// Shorts the cut key switcher.
        /// </summary>
        /// <param name="events">Events.</param>
        /// ======================================================================================================================================================================
        void ShortCutKeySwitcher(Event events)
        {
            if ( events.type == EventType.KeyDown && Event.current.keyCode == KeyCode.R )
            {
                SelectedBrush = BRUSH.ROTATION;
                ZeroOutLayerPosition();
            }

            if ( events.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Q )
            {
                SelectedBrush = BRUSH.PAINT;
                ZeroOutLayerPosition();
            }

            if ( events.type == EventType.KeyDown && Event.current.keyCode == KeyCode.E )
            {
                SelectedBrush = BRUSH.FLIP;
                ZeroOutLayerPosition();
            }

            if ( events.type == EventType.KeyDown && Event.current.keyCode == KeyCode.W )
            {
                SelectedBrush = BRUSH.SELECT;
                ZeroOutLayerPosition();
            }
        }
Пример #2
0
        /// ====================================================================================================================================================================== 
        /// <summary>
        /// Draws the brushes.
        /// </summary>
        /// ====================================================================================================================================================================== 
        void DrawBrushes()
        {
            GUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (!paintBrushimage)
                paintBrushimage = Resources.Load("paintTool", typeof(Texture)) as Texture;

            if (!paintBrushSelectedimage)
                paintBrushSelectedimage = Resources.Load("paintToolSelected", typeof(Texture)) as Texture;

            if (!selectBrushimage)
                selectBrushimage = Resources.Load("selectionTool", typeof(Texture)) as Texture;

            if (!selectBrushSelectedimage)
                selectBrushSelectedimage = Resources.Load("selectionToolSelected", typeof(Texture)) as Texture;

            if (!rotateBrushimage)
                rotateBrushimage = Resources.Load("rotationTool", typeof(Texture)) as Texture;

            if (!rotateBrushSelectedimage)
                rotateBrushSelectedimage = Resources.Load("rotationToolSelected", typeof(Texture)) as Texture;

            if (!flipBrushXimage)
                flipBrushXimage = Resources.Load("flipToolX", typeof(Texture)) as Texture;

            if (!flipBrushXSelectedimage)
                flipBrushXSelectedimage = Resources.Load("flipToolXSelected", typeof(Texture)) as Texture;

            GUIStyle buttonStyle = new GUIStyle (GUI.skin.button);
            buttonStyle.padding = new RectOffset(0,0,0,0);

            Texture PaintTexture = SelectedBrush == BRUSH.PAINT? paintBrushSelectedimage : paintBrushimage;
            Texture SelectTexture = SelectedBrush == BRUSH.SELECT? selectBrushSelectedimage : selectBrushimage;
            Texture RotateTexture = SelectedBrush == BRUSH.ROTATION? rotateBrushSelectedimage : rotateBrushimage;
            Texture FlipTexture = SelectedBrush == BRUSH.FLIP? flipBrushXSelectedimage : flipBrushXimage;

            if( GUILayout.Button( new GUIContent(PaintTexture, "Paint Brush"), buttonStyle,
                                 GUILayout.Width(PaintTexture.width*1.5f), GUILayout.Height(PaintTexture.height*1.5f) ) )
            {
                SelectedBrush = BRUSH.PAINT;
                ZeroOutLayerPosition();
            }

            if( GUILayout.Button( new GUIContent(SelectTexture, "Selection Brush"), buttonStyle,
                                 GUILayout.Width(SelectTexture.width*1.5f), GUILayout.Height(SelectTexture.height*1.5f) ) )
            {
                SelectedBrush = BRUSH.SELECT;
                ZeroOutLayerPosition();
            }

            if( GUILayout.Button( new GUIContent(FlipTexture, "Flip Brush"), buttonStyle,
                                 GUILayout.Width(FlipTexture.width*1.5f), GUILayout.Height(FlipTexture.height*1.5f) ) )
            {
                SelectedBrush = BRUSH.FLIP;
                ZeroOutLayerPosition();
            }

            if( GUILayout.Button( new GUIContent(RotateTexture, "Rotation Brush"), buttonStyle,
                                 GUILayout.Width(RotateTexture.width*1.5f), GUILayout.Height(RotateTexture.height*1.5f) ) )
            {
                SelectedBrush = BRUSH.ROTATION;
                ZeroOutLayerPosition();
            }

            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();
        }
Пример #3
0
        /// ======================================================================================================================================================================
        /// <summary>
        /// Initialization this instance.
        /// </summary>
        /// ====================================================================================================================================================================== 
        private void initialize()
        {
            // get all the Retro Tilemaps
            listOfTileAssets = RTStudio.Utils.Utils.GetAssetsOfType(typeof(RTStudio.TileSet), "asset");

            // get all the cameras
            listOfCameras = new List<Camera>( Camera.allCameras );

            // set target tilemap to the target
            targetTileMap = (RTStudio.TileMap) target;

            // create a nfew serialized object
            targetSerializedObject = new SerializedObject(target);
            targetSerializedObject.Update();

            // set the map dimensions and tile dimensions
            newTileMapDimensions = targetTileMap.mapDimensions;
            newTilesDimensions = targetTileMap.tileDimensions;

            // set up layers and callbacks as necessary
            layers = new ReorderableList(targetSerializedObject, targetSerializedObject.FindProperty("layers"), true, true, true, true);
            layers.drawHeaderCallback = LayerHeaderDelegate;
            layers.drawElementCallback = LayerDrawLDelegate;
            layers.onRemoveCallback = LayerRemoveDelegate;
            layers.onAddCallback = LayerAddDelegate;
            layers.onReorderCallback = LayerReorderDelegate;
            layers.onSelectCallback = LayerSelectedDelegate;
            layers.onChangedCallback = LayerChangedDelegate;

            // set to first tile set if exists
            if ( listOfTileAssets.Count > 0 && targetTileMap.tileSetIndex == -1)
            {
                targetTileMap.tileSetIndex = 0;
            }

            SelectedBrush = BRUSH.PAINT;

            // select the tileset
            if ( listOfTileAssets.Count > 0 && targetTileMap.tileSetIndex < listOfTileAssets.Count)
                targetTileMap.tileSet = (RTStudio.TileSet)listOfTileAssets[targetTileMap.tileSetIndex];

            // callback when an undo/redo is perfomed
            Undo.undoRedoPerformed += UndoCallback;
        }