Files
MI-38/Heli_with_panels/Assets/ui/test2Collider.cs
2022-07-04 13:15:35 +03:00

59 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test2Collider : MonoBehaviour
{
public Color _defaultRender;
public Color color = Color.green;
List<GameObject> green;
void Start()
{
GameObject parent = gameObject;
green = FindGameObjectInChildWithTag(parent, "green");
}
void OnMouseEnter()
{
Debug.Log($"íàâåëè ìûøü");
color.a = 0.5f;
OnColor();
}
void OnMouseExit()
{
if (!hlight.l)
{
color.a = 0f;
OnColor();
}
}
void OnColor()
{
foreach (GameObject gr in green)
{
gr.GetComponent<Renderer>().material.color = color;
}
}
public static List<GameObject> FindGameObjectInChildWithTag(GameObject parent, string tag)
{
Transform[] TempArray;
TempArray = parent.GetComponentsInChildren<Transform>();
var green = new List<GameObject>();
foreach (Transform gr in TempArray)
{
if (gr.gameObject.tag == tag)
green.Add(gr.gameObject);
}
Debug.Log($"green {green}");
return green;
//return null;
}
}