代码拉取完成,页面将自动刷新
同步操作将从 liyonghelpme/rongYaoDaLuCode 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using UnityEngine;
public class AdvancedPinchRotationSample : SampleBase
{
private Material originalMaterial;
public Material pinchAndRotationMaterial;
public PinchGestureRecognizer pinchGesture;
public Material pinchMaterial;
public float pinchScaleFactor = 0.02f;
public RotationGestureRecognizer rotationGesture;
public Material rotationMaterial;
public Transform target;
private bool CanBeginPinch(GestureRecognizer gr, FingerGestures.IFingerList touches)
{
return !this.rotationGesture.IsActive;
}
private bool CanBeginRotation(GestureRecognizer gr, FingerGestures.IFingerList touches)
{
return !this.pinchGesture.IsActive;
}
private void Gesture_OnStateChanged(GestureRecognizer source)
{
if ((source.PreviousState == GestureRecognizer.GestureState.Ready) && (source.State == GestureRecognizer.GestureState.InProgress))
{
base.UI.StatusText = source + " gesture started";
}
else if (source.PreviousState == GestureRecognizer.GestureState.InProgress)
{
if (source.State == GestureRecognizer.GestureState.Failed)
{
base.UI.StatusText = source + " gesture failed";
}
else if (source.State == GestureRecognizer.GestureState.Recognized)
{
base.UI.StatusText = source + " gesture ended";
}
}
this.UpdateTargetMaterial();
}
protected override string GetHelpText()
{
return "This sample demonstrates advanced use of the GestureRecognizer classes for Pinch and Rotation";
}
private void OnPinchMove(PinchGestureRecognizer source)
{
base.UI.StatusText = "Pinch updated by " + source.Delta + " degrees";
Transform transform = this.target.transform;
transform.localScale += (Vector3) ((source.Delta * this.pinchScaleFactor) * Vector3.one);
}
private void OnRotationMove(RotationGestureRecognizer source)
{
base.UI.StatusText = "Rotation updated by " + source.RotationDelta + " degrees";
this.target.Rotate(0f, 0f, source.RotationDelta);
}
protected override void Start()
{
base.Start();
base.UI.StatusText = "Use two fingers anywhere on the screen to rotate and scale the green object.";
this.originalMaterial = this.target.renderer.sharedMaterial;
this.pinchGesture.OnStateChanged += new FGComponent.EventDelegate<GestureRecognizer>(this.Gesture_OnStateChanged);
this.pinchGesture.OnPinchMove += new FGComponent.EventDelegate<PinchGestureRecognizer>(this.OnPinchMove);
this.pinchGesture.SetCanBeginDelegate(new GestureRecognizer.CanBeginDelegate(this.CanBeginPinch));
this.rotationGesture.OnStateChanged += new FGComponent.EventDelegate<GestureRecognizer>(this.Gesture_OnStateChanged);
this.rotationGesture.OnRotationMove += new FGComponent.EventDelegate<RotationGestureRecognizer>(this.OnRotationMove);
this.rotationGesture.SetCanBeginDelegate(new GestureRecognizer.CanBeginDelegate(this.CanBeginRotation));
}
private void UpdateTargetMaterial()
{
Material pinchAndRotationMaterial;
if (this.pinchGesture.IsActive && this.rotationGesture.IsActive)
{
pinchAndRotationMaterial = this.pinchAndRotationMaterial;
}
else if (this.pinchGesture.IsActive)
{
pinchAndRotationMaterial = this.pinchMaterial;
}
else if (this.rotationGesture.IsActive)
{
pinchAndRotationMaterial = this.rotationMaterial;
}
else
{
pinchAndRotationMaterial = this.originalMaterial;
}
this.target.renderer.sharedMaterial = pinchAndRotationMaterial;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。