代码拉取完成,页面将自动刷新
同步操作将从 liyonghelpme/rongYaoDaLuCode 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using UnityEngine;
public class ToolboxDragDropSample : SampleBase
{
public Rect dragModeButtonRect;
public Transform[] dragObjects;
public Collider dragPlane;
private DragPlaneMode dragPlaneMode;
public Collider dragSphere;
private Vector3[] initialPositions;
public TBInputManager inputMgr;
public Light pointlight;
protected override string GetHelpText()
{
return "This sample demonstrates the use of the Toolbox's Drag & Drop scripts";
}
private void OnGUI()
{
if (!base.UI.showHelp)
{
string str;
DragPlaneMode sphere;
SampleUI.ApplyVirtualScreen();
DragPlaneMode dragPlaneMode = this.dragPlaneMode;
if (dragPlaneMode == DragPlaneMode.Plane)
{
str = "Drag On Plane";
sphere = DragPlaneMode.Sphere;
}
else if (dragPlaneMode == DragPlaneMode.Sphere)
{
str = "Drag On Sphere";
sphere = DragPlaneMode.XY;
}
else
{
str = "Drag On XZ";
sphere = DragPlaneMode.Plane;
}
if (GUI.Button(this.dragModeButtonRect, str))
{
this.SetDragPlaneMode(sphere);
}
}
}
private void RestoreInitialPositions()
{
for (int i = 0; i < this.initialPositions.Length; i++)
{
this.dragObjects[i].position = this.initialPositions[i];
}
}
private void SaveInitialPositions()
{
this.initialPositions = new Vector3[this.dragObjects.Length];
for (int i = 0; i < this.initialPositions.Length; i++)
{
this.initialPositions[i] = this.dragObjects[i].position;
}
}
private void SetDragPlaneMode(DragPlaneMode mode)
{
switch (mode)
{
case DragPlaneMode.XY:
this.RestoreInitialPositions();
this.dragSphere.gameObject.active = false;
this.dragPlane.gameObject.active = false;
this.inputMgr.dragPlaneType = TBInputManager.DragPlaneType.XY;
break;
case DragPlaneMode.Plane:
this.RestoreInitialPositions();
this.dragSphere.gameObject.active = false;
this.dragPlane.gameObject.active = true;
this.inputMgr.dragPlaneCollider = this.dragPlane;
this.inputMgr.dragPlaneType = TBInputManager.DragPlaneType.UseCollider;
break;
case DragPlaneMode.Sphere:
this.RestoreInitialPositions();
this.dragSphere.gameObject.active = true;
this.dragPlane.gameObject.active = false;
this.inputMgr.dragPlaneCollider = this.dragSphere;
this.inputMgr.dragPlaneType = TBInputManager.DragPlaneType.UseCollider;
break;
}
this.dragPlaneMode = mode;
}
protected override void Start()
{
base.Start();
this.SaveInitialPositions();
this.SetDragPlaneMode(DragPlaneMode.XY);
}
private void ToggleLight()
{
this.pointlight.enabled = !this.pointlight.enabled;
}
private enum DragPlaneMode
{
XY,
Plane,
Sphere
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。