MyBotのセット③(マウスを乗せるとBlockの色が変化する)


マウスを乗せるとBlockの色が変化する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockManager : MonoBehaviour
{
public Color changeColor;
private Color initialColor;
private Renderer rend;
void Start()
{
rend = GetComponent<Renderer>();
initialColor = rend.material.color;
}
private void OnMouseEnter()
{
if (this.gameObject.tag == "Block")
{
rend.material.color = changeColor;
}
}
private void OnMouseExit()
{
if (this.gameObject.tag == "Block")
{
rend.material.color = initialColor;
}
}
}



【2021版】TowerD Ⅱ(全17回)
他のコースを見る

マウスを乗せるとBlockの色が変化する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockManager : MonoBehaviour
{
public Color changeColor;
private Color initialColor;
private Renderer rend;
void Start()
{
rend = GetComponent<Renderer>();
initialColor = rend.material.color;
}
private void OnMouseEnter()
{
if (this.gameObject.tag == "Block")
{
rend.material.color = changeColor;
}
}
private void OnMouseExit()
{
if (this.gameObject.tag == "Block")
{
rend.material.color = initialColor;
}
}
}



MyBotのセット③(マウスを乗せるとBlockの色が変化する)