示例#1
0
        void Awake()
        {
            rectTransform = this.GetComponent <RectTransform>();
            drawable      = this;
            // DEFAULT BRUSH SET HERE
            current_brush = PenBrush;

            //clonx drawable_sprite = this.GetComponent<SpriteRenderer>().sprite; //clonx 19.20.2018 holst.sprite;
            drawable_sprite = this.GetComponent <UnityEngine.UI.Image>().sprite;            //clonx 19.20.2018 holst.sprite;

            drawable_texture = drawable_sprite.texture;

            // Initialize clean pixels to use
            clean_colours_array = new Color[(int)drawable_sprite.rect.width * (int)drawable_sprite.rect.height];
            for (int x = 0; x < clean_colours_array.Length; x++)
            {
                clean_colours_array[x] = Reset_Colour;
            }

            // Should we reset our canvas image when we hit play in the editor?
            if (Reset_Canvas_On_Play)
            {
                ResetCanvas();
            }
        }
        void Awake()
        {
            drawable = this;
            // DEFAULT BRUSH SET HERE
            current_brush = PenBrush;

            SetClearState();
            // Should we reset our canvas image when we hit play in the editor?
            if (Reset_Canvas_On_Play)
            {
                ResetCanvas();
            }
        }
示例#3
0
    void Awake()
    {
        _nowDrawing   = false;
        drawable      = this;
        current_brush = PenBrush;

        drawable_sprite     = this.GetComponent <SpriteRenderer>().sprite;
        drawable_texture    = drawable_sprite.texture;
        clean_colours_array = new Color[(int)drawable_sprite.rect.width * (int)drawable_sprite.rect.height];
        for (int x = 0; x < clean_colours_array.Length; x++)
        {
            clean_colours_array[x] = Reset_Colour;
        }
        if (Reset_Canvas_On_Play)
        {
            ResetCanvas();
        }
    }
        //////////////////////////////////////////////////////////////////////////////



        // This is where the magic happens.
        // Detects when user is left clicking, which then call the appropriate function
        void Update()
        {
            if (current_brush == null)
            {
                current_brush = PenBrush;
            }

            // Is the user holding down the left mouse button?
            bool mouse_held_down = Input.GetMouseButton(0);

            if (mouse_held_down && !no_drawing_on_current_drag)
            {
                // Convert mouse coordinates to world coordinates
                Vector2 mouse_world_position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 5.8f));

                // Check if the current mouse position overlaps our image
                Collider2D hit = Physics2D.OverlapPoint(mouse_world_position, Drawing_Layers.value);
                if (hit != null && hit.transform != null)
                {
                    // We're over the texture we're drawing on!
                    // Use whatever function the current brush is
                    current_brush(mouse_world_position);
                }

                else
                {
                    // We're not over our destination texture
                    previous_drag_position = Vector2.zero;
                    if (!mouse_was_previously_held_down)
                    {
                        // This is a new drag where the user is left clicking off the canvas
                        // Ensure no drawing happens until a new drag is started
                        //no_drawing_on_current_drag = true;
                    }
                }
            }
            // Mouse is released
            else if (!mouse_held_down)
            {
                previous_drag_position     = Vector2.zero;
                no_drawing_on_current_drag = false;
            }
            mouse_was_previously_held_down = mouse_held_down;
        }
示例#5
0
    void Awake()
    {
        brush     = BrushType.Square;
        drawable  = this;
        currBrush = PenBrush;

        drawbleSprite = this.GetComponent <SpriteRenderer>().sprite;
        drawbleTextr  = drawbleSprite.texture;

        cleanColors = new Color[(int)drawbleSprite.rect.width * (int)drawbleSprite.rect.height];
        for (int x = 0; x < cleanColors.Length; x++)
        {
            cleanColors[x] = resetColor;
        }

        if (resetCanvas)
        {
            ResetCanvas();
        }
    }
示例#6
0
        void Start()
        {
            drawable = this;
            // DEFAULT BRUSH SET HERE
            current_brush = PenBrush;

            drawable_sprite  = this.GetComponent <SpriteRenderer>().sprite;
            drawable_texture = drawable_sprite.texture;

            // Initialize clean pixels to use
            clean_colours_array = new Color[(int)drawable_sprite.rect.width * (int)drawable_sprite.rect.height];
            for (int x = 0; x < clean_colours_array.Length; x++)
            {
                clean_colours_array[x] = Reset_Colour;
            }

            // Should we reset our canvas image when we hit play in the editor?
            if (Reset_Canvas_On_Play)
            {
                ResetCanvas();
            }
        }
示例#7
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Awake
        void Awake()
        {
            trackingChanges = new List <Line>();
            trackingAnim    = new Dictionary <GameObject, Line>();
            dbSceneUpload   = new DBScene();
            dbSceneSave     = new DBScene();
            // DEFAULT BRUSH SET HERE
            current_brush = PenBrush;
            //setsprite
            if (DrawingSettings.editingImage == null)
            {
                this.GetComponent <SpriteRenderer>().sprite = GameObject.Find("DrawingSettings").GetComponent <DrawingSettings>().spritePrefabs[this.transform.GetSiblingIndex()];
            }
            else
            {
                this.GetComponent <SpriteRenderer>().sprite = DrawingSettings.editingImage;
            }
            drawable_sprite  = this.GetComponent <SpriteRenderer>().sprite;
            drawable_texture = drawable_sprite.texture;

            if (DrawingSettings.editingImage == null)
            {
                // Initialize clean pixels to use
                clean_colours_array = new Color[(int)drawable_sprite.rect.width * (int)drawable_sprite.rect.height];

                for (int x = 0; x < clean_colours_array.Length; x++)
                {
                    clean_colours_array[x] = Reset_Colour;
                }

                // Should we reset our canvas image when we hit play in the editor?
                if (Reset_Canvas_On_Play)
                {
                    ResetCanvas();
                }
                //initially try to link button with this layer
                this.GetComponent <SpriteRenderer>().sortingOrder = this.transform.GetSiblingIndex();
            }
        }
示例#8
0
 // Helper method used by UI to set what brush the user wants
 // Create a new one for any new brushes you implement
 public void SetPenBrush()
 {
     // PenBrush is the NAME of the method we want to set as our current brush
     current_brush = PenBrush;
 }
示例#9
0
 public void SetPenBrush()
 {
     current_brush = PenBrush;
 }
示例#10
0
 public void SetPenBrush(bool isAnimation)
 {
     this.isAnimation = isAnimation;
     current_brush    = PenBrush;
 }
示例#11
0
 public void SetPenBrush()
 {
     currBrush = PenBrush;
 }