本文整理汇总了C#中EffectNode.SetLocalPosition方法的典型用法代码示例。如果您正苦于以下问题:C# EffectNode.SetLocalPosition方法的具体用法?C# EffectNode.SetLocalPosition怎么用?C# EffectNode.SetLocalPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EffectNode
的用法示例。
在下文中一共展示了EffectNode.SetLocalPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetEmitPosition
public void SetEmitPosition(EffectNode node)
{
Vector3 retPos = Vector3.zero;
if (Layer.EmitType == (int)EMITTYPE.BOX)
{
Vector3 center = Layer.EmitPoint;
float x = Random.Range(center.x - Layer.BoxSize.x / 2, center.x + Layer.BoxSize.x / 2);
float y = Random.Range(center.y - Layer.BoxSize.y / 2, center.y + Layer.BoxSize.y / 2);
float z = Random.Range(center.z - Layer.BoxSize.z / 2, center.z + Layer.BoxSize.z / 2);
retPos.x = x; retPos.y = y; retPos.z = z;
if (!Layer.SyncClient)
retPos = Layer.ClientTransform.position + retPos;
}
else if (Layer.EmitType == (int)EMITTYPE.POINT)
{
retPos = Layer.EmitPoint;
if (!Layer.SyncClient)
{
retPos = Layer.ClientTransform.position + Layer.EmitPoint;
}
}
else if (Layer.EmitType == (int)EMITTYPE.SPHERE)
{
retPos = Layer.EmitPoint;
if (!Layer.SyncClient)
{//ͬ���Ļ���NodeUpdate������λ��
retPos = Layer.ClientTransform.position + Layer.EmitPoint;
}
Vector3 r = Vector3.up * Layer.Radius;
Quaternion rot = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360));
retPos = rot * r + retPos;
}
//NOTICE LINE Direction currently is based on ClientTransform's forward
else if (Layer.EmitType == (int)EMITTYPE.LINE)
{
Vector3 left = Layer.EmitPoint + Layer.ClientTransform.localRotation * Vector3.forward * Layer.LineLengthLeft;
Vector3 right = Layer.EmitPoint + Layer.ClientTransform.localRotation * Vector3.forward * Layer.LineLengthRight;
Vector3 dir = right - left;
float p = (float)(node.Index + 1) / Layer.MaxENodes;
float length = dir.magnitude * p;
retPos = left + dir.normalized * length;
if (!Layer.SyncClient)
retPos = Layer.ClientTransform.TransformPoint(retPos);
}
else if (Layer.EmitType == (int)EMITTYPE.CIRCLE)
{
float p = (float)(node.Index + 1) / Layer.MaxENodes;
float rangle;
rangle = 360 * p;
Quaternion rotY = Quaternion.Euler(0, rangle, 0);
Vector3 v = rotY * (Vector3.right * Layer.Radius);
Quaternion rotTo = Quaternion.FromToRotation(Vector3.up, Layer.CircleDir);
retPos = rotTo * v;
if (!Layer.SyncClient)
retPos = Layer.ClientTransform.position + retPos + Layer.EmitPoint;
else
retPos = retPos + Layer.EmitPoint;
}
node.SetLocalPosition(retPos);
}