mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 00:25:38 +03:00
04.07.2022
This commit is contained in:
193
Heli_with_panels/Assets/Scripts/Panel2D/0112/drCol112.cs
Normal file
193
Heli_with_panels/Assets/Scripts/Panel2D/0112/drCol112.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class drCol112 : MonoBehaviour
|
||||
{
|
||||
protected Vector3 mousePosition;
|
||||
protected Vector2 a; // Vector2 deltaPosition
|
||||
public string typeDrag = null;
|
||||
public float dragMin, dragMax;
|
||||
public bool clamp = false;
|
||||
|
||||
[HideInInspector] public Vector2 dd;//для передачи в connection
|
||||
[HideInInspector] public bool _delta = false;//для передачи в connection
|
||||
|
||||
[HideInInspector] public bool isDrag = false;
|
||||
Manager man;
|
||||
|
||||
Camera cam;//камера для канваса с панелями
|
||||
private void Awake()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
calculationBegin();
|
||||
}
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
calculationDrag();
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = false;
|
||||
}
|
||||
isDrag = false;
|
||||
}
|
||||
public void calculationBegin()
|
||||
{
|
||||
//a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);
|
||||
isDrag = true;
|
||||
}
|
||||
public void calculationDrag()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
|
||||
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
|
||||
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
|
||||
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
{
|
||||
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = b;
|
||||
}
|
||||
}
|
||||
public void SetState(int b)
|
||||
{
|
||||
float bf = (clamp) ? Mathf.Clamp((float)b/100f, dragMin, dragMax) : b/100;
|
||||
//b += (int)(dragMax - dragMin) / 2;
|
||||
if (typeDrag == "x")
|
||||
transform.localPosition = new Vector3(bf, transform.localPosition.y, transform.localPosition.z);
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, bf, transform.localPosition.z);
|
||||
}
|
||||
|
||||
}
|
||||
=======
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class drCol112 : MonoBehaviour
|
||||
{
|
||||
protected Vector3 mousePosition;
|
||||
protected Vector2 a; // Vector2 deltaPosition
|
||||
public string typeDrag = null;
|
||||
public float dragMin, dragMax;
|
||||
public bool clamp = false;
|
||||
|
||||
[HideInInspector] public Vector2 dd;//для передачи в connection
|
||||
[HideInInspector] public bool _delta = false;//для передачи в connection
|
||||
|
||||
[HideInInspector] public bool isDrag = false;
|
||||
Manager man;
|
||||
|
||||
Camera cam;//камера для канваса с панелями
|
||||
private void Awake()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
calculationBegin();
|
||||
}
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
calculationDrag();
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = false;
|
||||
}
|
||||
isDrag = false;
|
||||
}
|
||||
public void calculationBegin()
|
||||
{
|
||||
//a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);
|
||||
isDrag = true;
|
||||
}
|
||||
public void calculationDrag()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
|
||||
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
|
||||
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
|
||||
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
{
|
||||
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = b;
|
||||
}
|
||||
}
|
||||
public void SetState(int b)
|
||||
{
|
||||
float bf = (clamp) ? Mathf.Clamp((float)b/100f, dragMin, dragMax) : b/100;
|
||||
//b += (int)(dragMax - dragMin) / 2;
|
||||
if (typeDrag == "x")
|
||||
transform.localPosition = new Vector3(bf, transform.localPosition.y, transform.localPosition.z);
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, bf, transform.localPosition.z);
|
||||
}
|
||||
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
Reference in New Issue
Block a user