Scratch effect - 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class scratchcardeffect : MonoBehaviour {

  

    public GameObject maskprefab;

    private bool isPressed = false;

    // Update is called once per frame

    void Update() {

        var mousePos = Input.mousePosition;

        mousePos.z = 3;

        mousePos = Camera.main.ScreenToWorldPoint (mousePos);

        

        if(isPressed == true) {

            GameObject maskSprite = Instantiate(maskprefab, mousePos, Quaternion.identity);

            maskSprite.transform.parent = gameObject.transform;

             

        } else {

        }

        if (Input.GetMouseButtonDown (0)) {

            Invoke("reveal", 5);

            isPressed = true;

        } else if (Input.GetMouseButtonUp (0)) {

            isPressed = false;

        }

    }

     

void reveal()

    {

        Destroy (this.gameObject);

    }

       

}

Slider change color 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;

public class sliderBG : MonoBehaviour

{

    [SerializeField] Slider SliderRed;

    [SerializeField] Slider SliderBlue;

    [SerializeField] Slider SliderGreen;

    Material colorMaterial;

    void Start()

    {

        colorMaterial = GetComponent<MeshRenderer>().material;

        

    }

    // Update is called once per frame

    void Update()

    {

        colorMaterial.color = new Color(SliderRed.value, SliderBlue.value, SliderGreen.value);

    }

}

Leave a comment

Log in with itch.io to leave a comment.