mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 01:25:38 +03:00
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class clickPanel : MonoBehaviour
|
|
{
|
|
public Color _defaultRender;
|
|
|
|
public Dictionary<string, GameObject> switchesList3D = new Dictionary<string, GameObject>(); // Обычные переключатели 3D
|
|
void Start()
|
|
{
|
|
/* Mesh myMesh = this.GetComponent<MeshFilter>().mesh;
|
|
DestroyImmediate(this.GetComponent<MeshCollider>());
|
|
var collider = this.gameObject.AddComponent<MeshCollider>();
|
|
collider.sharedMesh = myMesh; */
|
|
|
|
|
|
string s1 = this.name.Substring(this.name.Length - 7); // окончание названия панели например 0506_3D
|
|
string s2 = "Tumbler";
|
|
GameObject[] switches3D = GameObject.FindGameObjectsWithTag("toggle3D");
|
|
foreach (GameObject sw in switches3D)
|
|
{
|
|
if (sw.name.EndsWith(s1) && sw.name.StartsWith(s2))
|
|
{
|
|
//Debug.Log(sw.name);
|
|
sw.AddComponent<Switch3DRotate>();
|
|
switchesList3D.Add(sw.name, sw);
|
|
//Debug.Log("Имена 3D переключателей " + sw.name);
|
|
//Debug.Log("Кол-во 3D переключателей " + switches3D.Length);
|
|
}
|
|
}
|
|
|
|
//Debug.Log(this.name + " Имя этой панели");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void OnMouseDown()
|
|
{
|
|
Debug.Log(this.name + " кликаю панель");
|
|
if (string.Compare(this.name.Substring(this.name.Length - 2), "3D") == 0 && this.name != null)
|
|
{
|
|
string panel2d = this.name.Substring(0, this.name.Length - 3);
|
|
GameObject manager = GameObject.Find("Manager");
|
|
manager.GetComponent<Manager>().SwitchTo2D(panel2d);
|
|
}
|
|
}
|
|
|
|
void OnMouseEnter()
|
|
{
|
|
_defaultRender = GetComponent<Renderer>().material.color;
|
|
GetComponent<Renderer>().material.color = Color.green;
|
|
}
|
|
void OnMouseExit()
|
|
{
|
|
GetComponent<Renderer>().material.color = _defaultRender;
|
|
}
|
|
}
|
|
|
|
|
|
|