本文整理汇总了C#中UnityEngine.Transform.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.GetInstanceID方法的具体用法?C# Transform.GetInstanceID怎么用?C# Transform.GetInstanceID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Transform
的用法示例。
在下文中一共展示了Transform.GetInstanceID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Shake
public static IEnumerator Shake(Transform transform, float duration, Vector3 range, float decayStart = 1f)
{
// if we run multiple shakes then we can record the wrong originalPositino. For now just disallow multiple shakes on the same object
if (!ActiveShakes.Contains(transform.GetInstanceID()))
{
ActiveShakes.Add(transform.GetInstanceID());
var originalPosition = transform.localPosition;
var randomAngle = Random.Range(0, 361);
var decay = 0f;
var decayFactor = Mathf.Approximately(decayStart, 1) ? 0 : 1/(1 - decayStart);
var elapsedTime = 0f;
while (elapsedTime < duration)
{
if (transform.gameObject != null)
{
var percentComplete = elapsedTime/duration;
if (percentComplete >= decayStart)
{
decay = 1 - decayFactor + decayFactor*percentComplete;
// decay = Mathf.Clamp(v, 0.0f, 1.0f); // should be no need to clamp due to above conditional test!
}
// perlin movement
//var smoothRandom = SmoothRandom.GetVector3(speed);
//var target = originalPosition + Vector3.Scale(smoothRandom, range * decay);
//speed *= -1;
//range *= -1; //= new Vector3(range.x * -1, range.y * -1, range.z * -1);
// angle based
randomAngle += 180 + Random.Range(-60, 60); // mirror angle and add some varience.
var sinAngle = Mathf.Sin(randomAngle);
var cosAngle = Mathf.Cos(randomAngle);
var offset = new Vector3(cosAngle*sinAngle*range.x,
sinAngle*sinAngle*range.y,
cosAngle*range.z);
var target = originalPosition + (offset*(1 - decay));
transform.localPosition = target;
}
yield return null;
elapsedTime += Time.deltaTime;
}
// set back to original position - TODO consider movement from other scripts.
transform.localPosition = originalPosition;
ActiveShakes.Remove(transform.GetInstanceID());
}
}
示例2: InitDefaultGroupId
////////////////////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------------------------*/
public void InitDefaultGroupId(Transform pParentTx)
{
if ( pParentTx == null ) {
_DefaultGroupId = "Group-Root";
return;
}
HoverItemData parentData = pParentTx.GetComponent<HoverItemData>();
if ( parentData != null ) {
_DefaultGroupId = "Group-"+parentData.AutoId;
return;
}
_DefaultGroupId = "Group-Instance"+pParentTx.GetInstanceID();
}
示例3: RemoveCameraTarget
/// <summary>Remove a target from the camera.</summary>
/// <param name="targetTransform">The Transform of the target</param>
/// <param name="duration">The time it takes for this target to reach a zero influence. Use for a more progressive transition.</param>
public void RemoveCameraTarget(Transform targetTransform, float duration = 0f)
{
for (int i = 0; i < CameraTargets.Count; i++)
{
if (CameraTargets[i].TargetTransform.GetInstanceID() == targetTransform.GetInstanceID())
{
if (duration > 0)
{
StartCoroutine(AdjustTargetInfluenceRoutine(CameraTargets[i], 0, 0, duration, true));
}
else
CameraTargets.Remove(CameraTargets[i]);
}
}
}
示例4: GetCameraTarget
/// <summary>Gets the corresponding CameraTarget from an object's transform.</summary>
/// <param name="targetTransform">The Transform of the target</param>
public CameraTarget GetCameraTarget(Transform targetTransform)
{
for (int i = 0; i < CameraTargets.Count; i++)
{
if (CameraTargets[i].TargetTransform.GetInstanceID() == targetTransform.GetInstanceID())
{
return CameraTargets[i];
}
}
return null;
}
示例5: RemoveCinematicTarget
// <summary>Remove a cinematic target</summary>
/// <param name="targetTransform">The Transform component of the target</param>
public void RemoveCinematicTarget(Transform targetTransform)
{
for (int i = 0; i < CinematicTargets.Count; i++)
{
if (CinematicTargets[i].TargetTransform.GetInstanceID() == targetTransform.GetInstanceID())
{
CinematicTargets.Remove(CinematicTargets[i]);
}
}
}
示例6: AppendCameraTransform
private static void AppendCameraTransform(
StringBuilder result, int level, Transform trn,
Dictionary<int, List<Camera>> trnCams, Dictionary<int, bool> trnCamAncestors)
{
bool isAncestor = trnCamAncestors.ContainsKey(trn.GetInstanceID());
Component[] cmps = trn.gameObject.GetComponents<Component>();
string[] cmpStrs = new string[cmps.Length];
for (int i = 0; i < cmps.Length; i++) {
cmpStrs[i] = cmps[i].GetType().Name;
}
result.Append('+', level);
result.AppendFormat("{0} [{1}]", trn.name, string.Join(", ", cmpStrs));
if (isAncestor) {
result.Append(' ');
result.Append(Format(trn));
result.AppendLine();
// Only descend into descendents of transforms that are ancestors of
// cameras. This logs helpful context for camera transforms, without
// showing excessive internal model information.
int numChildTrns = trn.GetChildCount();
foreach (Transform child in trn) {
AppendCameraTransform(result, level + 1, child, trnCams, trnCamAncestors);
}
return;
}
if (trn.GetChildCount() > 0) {
result.Append(" (descendents hidden)");
}
result.AppendLine();
}
示例7: PersistedNameChange
public PersistedNameChange(Transform transform)
{
_transformId = transform.GetInstanceID();
_name = transform.gameObject.name;
}
示例8: Node
public Node(Transform transform)
{
_transform = transform;
if (null != _transform)
{
_parentTransform = _transform.parent;
}
if (null == transform)
{
_name = "ROOT";
}
else
{
_name = transform.name;
_transformId = transform.GetInstanceID();
_adapter = transform.GetComponent<ComponentAdapter>();
if (null != _adapter)
{
_adapterId = _adapter.GetInstanceID();
}
}
_description = string.Format("[{0}]", GuiLookup.PathToString(transform, "->"));
}