mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 01:15:41 +03:00
59 lines
1.2 KiB
C#
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;
|
|
}
|
|
|
|
}
|