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


C# Transform.GetInstanceID方法代码示例

本文整理汇总了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());
            }
        }
开发者ID:DanFlannel,项目名称:Pokemon_Battle_Simulator,代码行数:53,代码来源:ShakeHelper.cs

示例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();
        }
开发者ID:yonglehou,项目名称:Hover-VR-Interface-Kit,代码行数:18,代码来源:HoverItemDataRadio.cs

示例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]);
         }
     }
 }
开发者ID:EunoiaGames,项目名称:MTW,代码行数:18,代码来源:ProCamera2D.cs

示例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;
 }
开发者ID:EunoiaGames,项目名称:MTW,代码行数:13,代码来源:ProCamera2D.cs

示例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]);
         }
     }
 }
开发者ID:maynull,项目名称:LeftRightXoX,代码行数:12,代码来源:ProCamera2DCinematics.cs

示例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();
        }
开发者ID:Gonced8,项目名称:kerbcam,代码行数:33,代码来源:DebugUtil.cs

示例7: PersistedNameChange

 public PersistedNameChange(Transform transform)
 {
     _transformId = transform.GetInstanceID();
     _name = transform.gameObject.name;
 }
开发者ID:groov0v,项目名称:edriven-gui,代码行数:5,代码来源:PersistedNameChange.cs

示例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, "->"));
        }
开发者ID:groov0v,项目名称:edriven-gui,代码行数:26,代码来源:Node.cs


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