Commit 231009a5 authored by lijin's avatar lijin

Merge branch 'master' of gitlab.huolea.com:shujianhe/tusegamecolor

parents 5c9a76ed 20711c61
Assets/Art/GameEnd/圆.png

7.47 KB | W: | H:

Assets/Art/GameEnd/圆.png

3.38 KB | W: | H:

Assets/Art/GameEnd/圆.png
Assets/Art/GameEnd/圆.png
Assets/Art/GameEnd/圆.png
Assets/Art/GameEnd/圆.png
  • 2-up
  • Swipe
  • Onion skin
fileFormatVersion: 2 fileFormatVersion: 2
guid: f3a23023775d5604cbae05a554da8bce guid: 113fcf756ed6dfe4da29639c7600ef7a
TextureImporter: TextureImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}
......
...@@ -67,7 +67,7 @@ MonoBehaviour: ...@@ -67,7 +67,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Texture: {fileID: 2800000, guid: f3a23023775d5604cbae05a554da8bce, type: 3} m_Texture: {fileID: 2800000, guid: 113fcf756ed6dfe4da29639c7600ef7a, type: 3}
m_UVRect: m_UVRect:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
...@@ -567,7 +567,7 @@ MonoBehaviour: ...@@ -567,7 +567,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: f3a23023775d5604cbae05a554da8bce, type: 3} m_Sprite: {fileID: 21300000, guid: 113fcf756ed6dfe4da29639c7600ef7a, type: 3}
m_Type: 3 m_Type: 3
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
......
This source diff could not be displayed because it is too large. You can view the blob instead.
fileFormatVersion: 2
guid: f9972d7e7139d5f43bef9238e8d9dcad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -45,7 +45,7 @@ public class ScaleToImage : MonoBehaviour ...@@ -45,7 +45,7 @@ public class ScaleToImage : MonoBehaviour
private Vector3 OnInitPos; private Vector3 OnInitPos;
private void Start() private void Start()
{ {
canvasCamera=transform.parent.GetComponent<ScaleToImage>().canvasCamera; canvasCamera = transform.parent.GetComponent<ScaleToImage>().canvasCamera;
RegisterEvent(true); RegisterEvent(true);
StartCoroutine(Delay()); StartCoroutine(Delay());
...@@ -64,7 +64,7 @@ public class ScaleToImage : MonoBehaviour ...@@ -64,7 +64,7 @@ public class ScaleToImage : MonoBehaviour
private void ResetPos_Scale(object[] values) private void ResetPos_Scale(object[] values)
{ {
target.localScale= OnInitScale; target.localScale = OnInitScale;
target.position = OnInitPos; target.position = OnInitPos;
...@@ -74,6 +74,10 @@ public class ScaleToImage : MonoBehaviour ...@@ -74,6 +74,10 @@ public class ScaleToImage : MonoBehaviour
private void Update() private void Update()
{ {
#if UNITY_EDITOR
Editor_Scale();
return;
#endif
if (Input.touchCount == 2) if (Input.touchCount == 2)
{ {
Scale(); Scale();
...@@ -129,65 +133,54 @@ public class ScaleToImage : MonoBehaviour ...@@ -129,65 +133,54 @@ public class ScaleToImage : MonoBehaviour
} }
} }
private void RefreshScrollview() private void Editor_Scale()
{
target.gameObject.SetActive(false);
target.gameObject.SetActive(true);
scrollRect.inertia = true;
}
private void StopScaleToSetSize()
{
if (ScaleSize_List.Count > 0)
{
ChangeFontSize(ScaleSize_List[ScaleSize_List.Count - 1]);
ScaleSize_List.Clear();
}
}
private void ChangeFontSize(float scalesize)
{ {
GameMgr.Ins.tiMgr.SizeChange(scalesize); var mouse = Input.GetAxis("Mouse ScrollWheel");
} if (mouse != 0) //向前,该放大
private void Scale()
{
if (!isInit_Scale)
{ {
SetscrollRectEnable(false); SetscrollRectEnable(false);
//两指点位 var mouseposition = Input.mousePosition;
touch1 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position); pos = canvasCamera.ScreenToWorldPoint(mouseposition);
touch2 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position); pos = new Vector3(pos.x, pos.y, 0);
touch1 = new Vector3(touch1.x, touch1.y, 0);
touch2 = new Vector3(touch2.x, touch2.y, 0);
//图片的初始点位 //图片的初始点位
oriPos = new Vector3(target.position.x, target.position.y, 0); oriPos = new Vector3(target.position.x, target.position.y, 0);
float distance = Vector2.Distance(touch1, touch2) / 2f;
var normal = (touch1 - touch2).normalized; //指向中心的单位向量
pos = normal * distance + touch2; //两个手指中间的点
//指向手指中心的单位向量
ToFigerCenter = (pos - oriPos).normalized; ToFigerCenter = (pos - oriPos).normalized;
//距离 //距离
ToFigerdistance = Vector3.Distance(pos, oriPos); ToFigerdistance = Vector3.Distance(pos, oriPos);
oriScale = target.localScale.x;//开始的缩放值 oriScale = target.localScale.x;//开始的缩放值
isInit_Scale = true;
MoveValue = 1 / oriScale; MoveValue = 1 / oriScale;
SatrtScale = target.localScale.x; scale = mouse;
StartPos=target.position; bool isBig = scale > 0;
return; float scale_target = 0;
//控制缩放速度
scale = scale * scaleSpeed; //正的话就是放大图片
OnScale(scale_target, isBig);
delaytime = 0;
RefreshScrollview();
}
else
{
if (delaytime >= 0.5f && !scrollRect.enabled)
{
SetscrollRectEnable(true);
}
else
{
delaytime += Time.deltaTime;
}
} }
}
//两指缩放比例 float delaytime = 0;
float nowdis = Vector3.Distance(canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position), canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position)); private void OnScale(float scale_target, bool isBig)
scale = nowdis / Vector3.Distance(touch1, touch2); //大于1是放大,小于是缩小 {
bool isBig = scale > 1;
float scale_target = 0;
//控制缩放速度
scale = (scale - 1) * scaleSpeed; //正的话就是放大图片
if (scale < 0) if (scale < 0)
{ {
scale = scale * oriScale * scaleSpeed; //缩小速度 scale = scale * oriScale * scaleSpeed; //缩小速度
...@@ -252,7 +245,66 @@ public class ScaleToImage : MonoBehaviour ...@@ -252,7 +245,66 @@ public class ScaleToImage : MonoBehaviour
ScaleSize_List.Clear(); ScaleSize_List.Clear();
ChangeFontSize(NowScale); ChangeFontSize(NowScale);
} }
}
private void RefreshScrollview()
{
target.gameObject.SetActive(false);
target.gameObject.SetActive(true);
scrollRect.inertia = true;
}
private void StopScaleToSetSize()
{
if (ScaleSize_List.Count > 0)
{
ChangeFontSize(ScaleSize_List[ScaleSize_List.Count - 1]);
ScaleSize_List.Clear();
}
}
private void ChangeFontSize(float scalesize)
{
GameMgr.Ins.tiMgr.SizeChange(scalesize);
}
private void Scale()
{
if (!isInit_Scale)
{
SetscrollRectEnable(false);
//两指点位
touch1 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position);
touch2 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position);
touch1 = new Vector3(touch1.x, touch1.y, 0);
touch2 = new Vector3(touch2.x, touch2.y, 0);
//图片的初始点位
oriPos = new Vector3(target.position.x, target.position.y, 0);
float distance = Vector2.Distance(touch1, touch2) / 2f;
var normal = (touch1 - touch2).normalized;
pos = normal * distance + touch2; //两个手指中间的点
//指向手指中心的单位向量
ToFigerCenter = (pos - oriPos).normalized;
//距离
ToFigerdistance = Vector3.Distance(pos, oriPos);
oriScale = target.localScale.x;//开始的缩放值
isInit_Scale = true;
MoveValue = 1 / oriScale;
SatrtScale = target.localScale.x;
StartPos = target.position;
return;
}
//两指缩放比例
float nowdis = Vector3.Distance(canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position), canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position));
scale = nowdis / Vector3.Distance(touch1, touch2); //大于1是放大,小于是缩小
bool isBig = scale > 1;
float scale_target = 0;
OnScale(scale_target, isBig);
} }
private void SetscrollRectEnable(bool enable) private void SetscrollRectEnable(bool enable)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment