35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace Models
|
|
{
|
|
public class VirtualSkeleton : Bond
|
|
{
|
|
private readonly GameObject _virtualSkeleton;
|
|
|
|
public VirtualSkeleton(GameObject start,GameObject end,float scale) : base(start,end,scale)
|
|
{
|
|
_virtualSkeleton = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
|
|
|
|
_virtualSkeleton.transform.localScale = new Vector3(scale/2, scale/2, scale/2);
|
|
|
|
_virtualSkeleton.GetComponent<Renderer>().material.color = Color.white;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 覆盖基类的更新方法
|
|
/// </summary>
|
|
public new void UpdateBond()
|
|
{
|
|
var startPos = Start.transform.position;
|
|
var endPos = End.transform.position;
|
|
|
|
var rightPosition = (startPos + endPos) / 2;
|
|
var rightRotation = endPos - startPos;
|
|
var lThickness = 0.2f;
|
|
|
|
_virtualSkeleton.transform.position = rightPosition;
|
|
_virtualSkeleton.transform.rotation = Quaternion.FromToRotation(Vector3.up, rightRotation);
|
|
_virtualSkeleton.transform.localScale = new Vector3(lThickness, lThickness, lThickness);
|
|
}
|
|
}
|
|
} |