Last active
May 12, 2021 09:43
-
-
Save tsubaki/d832efacb5f5f4664fcf to your computer and use it in GitHub Desktop.
ボタンのクリックを押しながら背面をクリックするのを防ぐ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.EventSystems; | |
public class ChangeColor : MonoBehaviour { | |
MaterialPropertyBlock block; | |
void Start() | |
{ | |
block = new MaterialPropertyBlock(); | |
block.SetColor("_Color", Color.red); | |
} | |
void OnMouseUp () | |
{ | |
GetComponent<Renderer>().SetPropertyBlock(null); | |
} | |
void OnMouseDown() | |
{ | |
if(EventSystem.current.IsPointerOverGameObject()){ | |
return; | |
} | |
GetComponent<Renderer>().SetPropertyBlock(block); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment