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


C# Transform.GetComponentInParent方法代码示例

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


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

示例1: GetDoors

        // Look for doors on object, then on direct parent
        private DaggerfallStaticDoors GetDoors(Transform transform, out Transform owner)
        {
            owner = null;
            DaggerfallStaticDoors doors = transform.GetComponent<DaggerfallStaticDoors>();
            if (!doors)
            {
                doors = transform.GetComponentInParent<DaggerfallStaticDoors>();
                if (doors)
                    owner = doors.transform;
            }
            else
            {
                owner = doors.transform;
            }

            return doors;
        }
开发者ID:Nystul-the-Magician,项目名称:daggerfall-unity,代码行数:18,代码来源:PlayerActivate.cs

示例2: MakeRipple

        public static GameObject MakeRipple(Vector3 position, Transform parent, int size, float animSpeed, float startAlpha, float endAlpha, Color color, Vector3 endPosition)
        {
            currentRipple = GameObject.Instantiate (ripplePrefab) as GameObject;

            Canvas parentCanvas = parent.GetComponentInParent<Canvas> ();

            if (parentCanvas.renderMode == RenderMode.ScreenSpaceOverlay)
                currentRipple.GetComponent<RectTransform>().position = position;
            else
                currentRipple.transform.localPosition = position;

            currentRipple.transform.SetParent (parent);

            currentRipple.GetComponent<RectTransform> ().localRotation = new Quaternion (0f, 0f, 0f, 0f);

            currentRipple.GetComponent<RippleAnim> ().MakeRipple (size, animSpeed, startAlpha, endAlpha, color, endPosition);

            return currentRipple;
        }
开发者ID:tejerolucas,项目名称:Social-Drive,代码行数:19,代码来源:RippleControl.cs

示例3: FindTeleportRoot

        /**
         * Finds the best transform parent for the given object to use when teleporting.
         */
        protected Transform FindTeleportRoot(Transform obj)
        {
            /*
             * Find the rigidbody/character controller we are part of.
             * Failing that, find the root collider.
             * Failing that, choose {obj}.
             *
             */

            Transform movementRoot = obj;
            var logicalRoot = (Component)obj.GetComponentInParent<Rigidbody>() ?? obj.GetComponentInParent<CharacterController>();

            if (logicalRoot) movementRoot = logicalRoot.transform;
            else {
            Transform current = obj.parent;

            while (current) {
                Component component = current.GetComponent<Rigidbody>();
                if (!component) component = current.GetComponent<Collider>();

                if (component) movementRoot = component.transform;

                current = current.parent;
            }
            }

            return movementRoot;
        }
开发者ID:mmandel,项目名称:8Nights2,代码行数:31,代码来源:Portal.cs

示例4: GetPanel

 /// <summary>
 /// Get closest parent panel for transform. if not found - new panel will be created at root GameObject.
 /// </summary>
 /// <returns>The panel.</returns>
 /// <param name="obj">Widget.</param>
 public static GuiPanel GetPanel(Transform obj)
 {
     if (obj == null) {
         return null;
     }
     var panel = obj.GetComponentInParent<GuiPanel> ();
     if (panel == null) {
         panel = obj.transform.root.gameObject.AddComponent<GuiPanel> ();
     }
     return panel;
 }
开发者ID:Leopotam,项目名称:LeopotamGroupLibraryUnity,代码行数:16,代码来源:GuiPanel.cs

示例5: FindCanvas

		/// <summary>
		/// Finds the canvas.
		/// </summary>
		/// <returns>The canvas.</returns>
		/// <param name="currentObject">Current object.</param>
		static public Transform FindCanvas(Transform currentObject)
		{
			var canvas = currentObject.GetComponentInParent<Canvas>();
			if (canvas==null)
			{
				return null;
			}
			return canvas.transform;
		}
开发者ID:matmuze,项目名称:cellVIEW_color,代码行数:14,代码来源:Utilites.cs

示例6: areGizmosDisabled

    protected static bool areGizmosDisabled(Transform transform) {
      bool isDisabled = false;
      do {
        var toggle = transform.GetComponentInParent<RuntimeGizmoToggle>();
        if (toggle == null) {
          break;
        }

        if (!toggle.enabled) {
          isDisabled = true;
          break;
        }

        transform = transform.parent;
      } while (transform != null);

      return isDisabled;
    }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:18,代码来源:RuntimeGizmoManager.cs

示例7: Start

        // Use this for initialization
        void Start()
        {
            // Get relative variables for script use
            _player = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Transform>();
            _playerCam = _player.GetComponent<Camera>();
            _defaultRot = Moveable.rotation.eulerAngles;
            _playerBase = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
            _normalisedDefaultRot = new Vector3(0, _defaultRot.y, 0);
            _cam = GetComponent<Camera>();
            _cam.fieldOfView = _player.GetComponent<Camera>().fieldOfView;

            // Get the positions of the area bounds
            _bounds = new Vector3[Bounds.Length];
            for (int i = 0; i < Bounds.Length; i++) {
                _bounds[i] = Bounds[i].position;
            }

            // If there are requests for additional render depths, create the requirements
            _additionalDepthRenderers = new GameObject[Helper.renderDepth];
            for (int i = 0; i < Helper.renderDepth; i++) {
                _additionalDepthRenderers[i] = Instantiate(Moveable.gameObject);
                _additionalDepthRenderers[i].GetComponentInChildren<CameraRenderPosition>().enabled = false;
                _additionalDepthRenderers[i].GetComponentInChildren<Camera>().depth = -(i + 2);
                _additionalDepthRenderers[i].transform.parent = Moveable.parent;
            }

            // Get rotation Quaternions between the two points
            _relativePlayerRot = Quaternion.FromToRotation(RenderPosition.forward, -PointOfView.forward);
            _relativePortalRot = Quaternion.FromToRotation(RenderPosition.forward, PointOfView.forward);

            // Get external script references
            _linkedScript = PointOfView.GetComponentInChildren<CameraRenderPosition>();
            _playerControl = _player.GetComponentInParent<OVRPlayerController>();
        }
开发者ID:nboxhallburnett,项目名称:IndividualProject,代码行数:35,代码来源:CameraRenderPosition.cs


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