当前位置: 首页>>代码示例>>C#>>正文


C# BodyPart.PasteShapeSizeToOpposite方法代码示例

本文整理汇总了C#中BodyPart.PasteShapeSizeToOpposite方法的典型用法代码示例。如果您正苦于以下问题:C# BodyPart.PasteShapeSizeToOpposite方法的具体用法?C# BodyPart.PasteShapeSizeToOpposite怎么用?C# BodyPart.PasteShapeSizeToOpposite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BodyPart的用法示例。


在下文中一共展示了BodyPart.PasteShapeSizeToOpposite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawShapeHandle

	/*
	 * Draw a collider gizmo for a specified part
	 * */
	public static void DrawShapeHandle(BodyPart part, bool drawOpposite)
	{
		// early out if the part is null or the part has no shape
		if (part==null || part.shapeType==ShapeType.None || !part.isCollider) return;
		
		// store the current color
		Color oldColor = Handles.color;
		
		// set undo snapshot
		BodyPart[] parts = new BodyPart[1];
		if(isSymmetrical && part.oppositePart!=null)
		{
			parts = new BodyPart[2];
			parts[1] = part.oppositePart;
			parts[1].oppositePart = part; // BUG: No idea why I need to do this
		}
		parts[0] = part;
		Undo.SetSnapshotTarget(parts, string.Format("Change Shape"));
		
		// create shape handles
		if (isShapeHandleEnabled)
		{
			// use radius if shape is capsule or sphere
			float radius = 0f;
			
			// compute the size to draw the shape handle based on the part's scale
			Vector3 shapeHandleSize = GetShapeHandleSize(part);
			
			// draw the correct handle based on shapeType
			switch (part.shapeType)
			{
			case ShapeType.Box:
				// create handles
				ShapeHandles.WireBox(ref shapeHandleSize, part.bone.TransformPoint(part.shapeCenter), part.bone.rotation,"");
				
				// apply the result
				DoShapeSizeThresholdTest(part, shapeHandleSize);
				
				// handle symmetry
				if (parts.Length>1)
				{
					part.PasteShapeSizeToOpposite(isScaleSymmetrical);
					if (drawOpposite)
					{
						// get the opposite part's dimensions in case its local scale is different
						shapeHandleSize = GetShapeHandleSize(parts[1]);
						
						// ghost the opposite part
						CustomHandleUtilities.SetHandleColor(oldColor, symmetryAlpha);
						ShapeHandles.WireBox(ref shapeHandleSize, parts[1].bone.TransformPoint(parts[1].shapeCenter), parts[1].bone.rotation,"");
						
						// apply the result
						DoShapeSizeThresholdTest(parts[1], shapeHandleSize);
						parts[1].PasteShapeSizeToOpposite(isScaleSymmetrical);
					}
				}
				break;
			case ShapeType.Capsule:
				// get handle properties
				float height = 0f;
				Quaternion capsuleOrientation = Quaternion.identity;
				GetCapsuleProperties(part, ref height, ref radius, ref capsuleOrientation);
				
				// draw handle
				ShapeHandles.WireCapsule(ref radius, ref height, part.bone.TransformPoint(part.shapeCenter), part.bone.rotation*part.shapeRotation*capsuleOrientation, "");
				
				// apply result
				DoShapeSizeThresholdTest(part, CapsuleToSize(part, height, radius));
				
				// handle symmetry
				if (parts.Length>1)
				{
					part.PasteShapeSizeToOpposite(isScaleSymmetrical);
					if (drawOpposite)
					{
						// get the opposite part's dimensions in case its local scale is different
						GetCapsuleProperties(parts[1], ref height, ref radius, ref capsuleOrientation);
						
						// ghost the opposite part
						CustomHandleUtilities.SetHandleColor(oldColor, symmetryAlpha);
						ShapeHandles.WireCapsule(ref radius, ref height, parts[1].bone.TransformPoint(parts[1].shapeCenter), parts[1].bone.rotation*parts[1].shapeRotation*capsuleOrientation, "");
						
						// apply the result
						DoShapeSizeThresholdTest(parts[1], CapsuleToSize(parts[1], height, radius));
						parts[1].PasteShapeSizeToOpposite(isScaleSymmetrical);
					}
				}
				break;
			case ShapeType.Sphere:
				// create a simple radius handle
				float oldRadius = Mathf.Max(
					part.shapeSize.x*part.bone.lossyScale.x*0.5f, 
					part.shapeSize.y*part.bone.lossyScale.y*0.5f, 
					part.shapeSize.z*part.bone.lossyScale.z*0.5f);
				radius = Handles.RadiusHandle(part.bone.rotation*part.shapeRotation, part.bone.TransformPoint(part.shapeCenter), oldRadius);
				if (Mathf.Abs(radius-oldRadius)>changeThreshold)
				{
//.........这里部分代码省略.........
开发者ID:hyper-active,项目名称:virtual-reality,代码行数:101,代码来源:BodyPartEditor.cs


注:本文中的BodyPart.PasteShapeSizeToOpposite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。