Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Glass : MonoBehaviour
- {
- //цвет стакана, задается в Inspector
- public Color colorToCompare;
- private void OnCollisionEnter(Collision collision)
- {
- if (collision.gameObject.GetComponent<Renderer>() == null)
- return;
- var ballColor = collision.gameObject.GetComponent<Renderer>().material.color;
- if (CompareColors(colorToCompare, ballColor))
- {
- Debug.Log("Цвета одинаковы");
- }
- }
- bool CompareColors (Color origin, Color color)
- {
- return ((origin.r == color.r) && (origin.b == color.b) && (origin.g == color.b) && (origin.a == color.a));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement