mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 01:15:41 +03:00
06.07.2022
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -103,110 +102,4 @@ public class ClickGruzCube2 : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
=======
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClickGruzCube2 : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float z;
|
||||
private Vector3 startpos, endpos;// = new Vector3(-5.4f, 2.5f, 1.5f);
|
||||
private Coroutine coroutine, coroutine2;
|
||||
float cameraMoveCurTime, cameraMoveMaxTime = 1f;
|
||||
float scrollSpeed = 0.5f;
|
||||
Renderer rend;
|
||||
float eulerAngZ;
|
||||
[HideInInspector] public Manager manager;
|
||||
|
||||
bool flag_rev;
|
||||
public Texture2D SampleTexture;
|
||||
public Texture2D NormalTexture;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
manager = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
endpos =new Vector3(-5.4f, 2.5f,z);
|
||||
rend = GetComponent<Renderer>();
|
||||
rend.enabled = false;
|
||||
eulerAngZ = transform.localEulerAngles.z;
|
||||
RotationArrow();
|
||||
|
||||
flag_rev = false;
|
||||
|
||||
}
|
||||
void OnMouseEnter()
|
||||
{
|
||||
RotationArrow();
|
||||
rend.enabled = true;
|
||||
coroutine2 = StartCoroutine(GoToArrow());
|
||||
}
|
||||
void OnMouseExit()
|
||||
{
|
||||
rend.enabled = false;
|
||||
if (coroutine2 != null) StopCoroutine(coroutine2);
|
||||
}
|
||||
private void OnMouseDown()
|
||||
{
|
||||
if (manager.viewmode == 1) return;
|
||||
cameraMoveCurTime = 0;
|
||||
startpos = Camera.main.transform.position;
|
||||
coroutine = StartCoroutine(GoToCube());
|
||||
}
|
||||
IEnumerator GoToCube()
|
||||
{
|
||||
float d;
|
||||
while (cameraMoveCurTime < cameraMoveMaxTime)
|
||||
{
|
||||
cameraMoveCurTime += Time.deltaTime;
|
||||
d = cameraMoveCurTime / cameraMoveMaxTime;
|
||||
Camera.main.transform.position = Vector3.Lerp(startpos, endpos, d);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
}
|
||||
void RotationArrow()
|
||||
{
|
||||
if (Camera.main.transform.localEulerAngles.y > -90 && Camera.main.transform.localEulerAngles.y < 90|| Camera.main.transform.localEulerAngles.y > 270)
|
||||
{
|
||||
flag_rev = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag_rev = false;
|
||||
}
|
||||
|
||||
}
|
||||
IEnumerator GoToArrow()
|
||||
{
|
||||
while (rend.enabled)
|
||||
{
|
||||
float offset = -Time.time * scrollSpeed;
|
||||
if (flag_rev)
|
||||
{
|
||||
rend.material.SetTexture("_MainTex", SampleTexture);
|
||||
rend.material.SetTextureOffset("_MainTex", new Vector2(-offset, 0));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rend.material.SetTexture("_MainTex", NormalTexture);
|
||||
rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
}
|
||||
public void FixedUpdate()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (coroutine != null) StopCoroutine(coroutine);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -43,49 +42,3 @@ public class Switch2view : MonoBehaviour, IPointerClickHandler//, IPointerEnterH
|
||||
manager.skv.SetActive(true);
|
||||
}*/
|
||||
}
|
||||
=======
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Switch2view : MonoBehaviour, IPointerClickHandler//, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[HideInInspector] public Manager manager;
|
||||
void Start()
|
||||
{
|
||||
manager = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
/* manager.viewmode = 3; // Свободный обзор
|
||||
//if(manager.mode == "free") manager.mode = "view";
|
||||
//manager.mode = "view";
|
||||
manager.cabines2d.SetActive(false);
|
||||
manager.fusel.SetActive(true);
|
||||
manager.skv.SetActive(true);
|
||||
|
||||
//manager.ViewBackButton.GetComponent<Button>().onClick.Invoke();
|
||||
// Выключаем коллайдеры для внутренней и пассажирской кабины
|
||||
manager.DisablePassCabineCollider();
|
||||
manager.DisablePilotCabineCollider();
|
||||
*/
|
||||
if (manager == null)
|
||||
manager = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
if (!manager.is3D) manager.SwitchTo3D();
|
||||
manager.switchModeView();
|
||||
|
||||
manager.mouseEnterUI();
|
||||
}
|
||||
/*public void OnMouseDown()
|
||||
{
|
||||
manager.viewmode = 3; // Свободный обзор
|
||||
//if (manager.mode == "free") manager.mode = "view";
|
||||
manager.cabines2d.SetActive(false);
|
||||
manager.fusel.SetActive(true);
|
||||
manager.skv.SetActive(true);
|
||||
}*/
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
@@ -85,91 +84,3 @@ public class hint : MonoBehaviour, IPointerEnterHandler, IPointerDownHandler, IP
|
||||
|
||||
}
|
||||
}
|
||||
=======
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class hint : MonoBehaviour, IPointerEnterHandler, IPointerDownHandler, IPointerExitHandler, IPointerUpHandler
|
||||
{
|
||||
[HideInInspector] public Manager manager;
|
||||
public static bool IsHint = true;
|
||||
private Image[] img;
|
||||
|
||||
private GameObject hintObj;
|
||||
public GameObject go;
|
||||
[SerializeField]
|
||||
private string t;
|
||||
void Start()
|
||||
{
|
||||
img = this.GetComponentsInChildren<Image>();
|
||||
img[0].gameObject.SetActive(true);
|
||||
img[1].gameObject.SetActive(false);
|
||||
gameObject.GetComponentInChildren<Image>().color = (IsHint) ? Color.green : Color.white;
|
||||
manager = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
IsHint = !IsHint;
|
||||
gameObject.GetComponentInChildren<Image>().color = (IsHint) ? Color.green : Color.white;
|
||||
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
img[0].gameObject.SetActive(false);
|
||||
img[1].gameObject.SetActive(true);
|
||||
gameObject.GetComponentInChildren<Image>().color = (IsHint) ? Color.green : Color.white;
|
||||
|
||||
var h = GameObject.Find("hintContainer");
|
||||
Debug.Log(h);
|
||||
if (h != null)
|
||||
{
|
||||
Destroy(h);
|
||||
}
|
||||
hintObj = OnHint(this.gameObject, go, t);
|
||||
|
||||
//manager.mouseEnterUI();
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
gameObject.GetComponentInChildren<Image>().color = Color.green;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
img[0].gameObject.SetActive(true);
|
||||
img[1].gameObject.SetActive(false);
|
||||
gameObject.GetComponentInChildren<Image>().color = (IsHint) ? Color.green : Color.white;
|
||||
Destroy(hintObj);
|
||||
//manager.mouseExitUI();
|
||||
}
|
||||
public GameObject OnHint(GameObject btn, GameObject objGo, string t)
|
||||
{
|
||||
Vector2 hintPos = new Vector2(btn.transform.localPosition.x + 15, btn.transform.localPosition.y + 55);//позиция хинта
|
||||
GameObject hint = Instantiate(objGo, btn.transform.parent);//создание хинта
|
||||
hint.name = "hintContainer";
|
||||
hint.transform.localPosition = hintPos;//позиция хинта устанавливаем
|
||||
var hintBase = hint.GetComponentInChildren<Image>();
|
||||
Text txt = hint.GetComponentInChildren<Text>();
|
||||
txt.text = t;
|
||||
var s = txt.text.Length;
|
||||
//Debug.Log($"s = {s}");
|
||||
RectTransform rectTransformText = txt.GetComponent<RectTransform>();
|
||||
rectTransformText.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, s * 10 + 20);
|
||||
RectTransform rectTransformBase = hintBase.GetComponent<RectTransform>();
|
||||
rectTransformBase.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, rectTransformText.rect.width + 35);
|
||||
if ((rectTransformBase.rect.width + hintBase.transform.position.x) > Screen.width)
|
||||
{
|
||||
hint.transform.localPosition = new Vector2(hint.transform.localPosition.x - rectTransformBase.rect.width/2 + 25, hint.transform.localPosition.y);
|
||||
var hintTr = hint.transform.GetChild(1).GetComponent<Image>();
|
||||
hintTr.transform.localPosition = new Vector2(hintTr.transform.localPosition.x + rectTransformBase.rect.width/2 - 30, hintTr.transform.localPosition.y);
|
||||
//Debug.Log($"hintTr.name = {hintTr.name}");
|
||||
}
|
||||
return hint;
|
||||
|
||||
}
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
|
||||
Reference in New Issue
Block a user