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


C# Canvas.GetComponent方法代码示例

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


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

示例1: GetScreenPosition

 public static Vector3 GetScreenPosition(Transform transform, Canvas canvas, Camera cam)
 {
     Vector3 pos;
     float width = canvas.GetComponent<RectTransform>().sizeDelta.x;
     float height = canvas.GetComponent<RectTransform>().sizeDelta.y;
     float x = Camera.main.WorldToScreenPoint(transform.position).x / Screen.width;
     float y = Camera.main.WorldToScreenPoint(transform.position).y / Screen.height;
     pos = new Vector3(width * x - width / 2, y * height - height / 2);
     return pos;
 }
开发者ID:hurleybird,项目名称:GameJam2016MobaThing,代码行数:10,代码来源:GetScreenPos.cs

示例2: start

 public void start(Canvas canvas, float charaImagePosY)
 {
     for (int n = 0; n < chara.Length; n++)
     {
         chara[n].init(canvas.GetComponent<RectTransform>().rect.width / (chara.Length * 2) * (2 * n + 1), charaImagePosY, 0,canvas);
     }
 }
开发者ID:ponJuice,项目名称:RunGame,代码行数:7,代码来源:ADVElement.cs

示例3: NavigateForwards

    public override void NavigateForwards(Canvas canvas)
    {
        Debug.Log("NavigateForwards to " + canvas.name);
        if(ActiveCanvas != null)
        {
            navStack.Push(ActiveCanvas);

            var rt = ActiveCanvas.GetComponent<RectTransform>();
            rt.offsetMin = new Vector2(0, -rt.rect.height);
            rt.offsetMax = new Vector2(0, rt.rect.height);
            ActiveCanvas.gameObject.SetActive(false);
        }

        ActiveCanvas = canvas;

        if(ActiveCanvas != null)
        {
            ActiveCanvas.gameObject.SetActive(true);
            var rt = ActiveCanvas.GetComponent<RectTransform>();
            rt.offsetMin = new Vector2(0, 0);
            rt.offsetMax = new Vector2(0, 0);

            //rt.rect.Set(0, 0, rt.rect.width, rt.rect.height);

            SelectFirstVisibleItem();
        }
    }
开发者ID:PeteJBB,项目名称:SupremeViolence,代码行数:27,代码来源:PerPlayerUiWindow.cs

示例4: InitGameplayController

	public void InitGameplayController(Canvas p_UICanvas)
	{
		ui_Canvas = p_UICanvas;
		uiCanvasRect = ui_Canvas.GetComponent<RectTransform>();
		UpdateBuildButton();
		DisableBuildButton();
	}
开发者ID:JosephCoppola,项目名称:Joestown,代码行数:7,代码来源:Gameplay_Controller.cs

示例5: Start

        public int KeepWindowInCanvas = 5;            // # of pixels of the window that must stay inside the canvas view.

        // Use this for initialization
        void Start()
        {
            m_transform = GetComponent<RectTransform>();
            m_originalCoods = m_transform.position;
            m_canvas = GetComponentInParent<Canvas>();
            m_canvasRectTransform = m_canvas.GetComponent<RectTransform>();
        }
开发者ID:illvisation,项目名称:cellVIEW_bdbox,代码行数:10,代码来源:UIWindowBase.cs

示例6: Start

	// Use this for initialization
	void Start () 
    {
        canvas = GameObject.FindObjectOfType<Canvas>();
        sceneManager = canvas.GetComponent<csBedroomSceneManager>();
        kagotchi = GameObject.Find("Kagotchi");
        on = true;
	}
开发者ID:Kagotchi,项目名称:KagotchiV1,代码行数:8,代码来源:csBedroomButtons.cs

示例7: WorldToCanvasPosition

 public static Vector3 WorldToCanvasPosition(Vector3 pos, Canvas canvas, Camera viewCam)
 {
     RectTransform canvasRectT = canvas.GetComponent<RectTransform>();
     Vector3 screenPos = viewCam.WorldToScreenPoint(pos);
     Vector3 worldPos = Vector2.zero;
     RectTransformUtility.ScreenPointToWorldPointInRectangle(canvasRectT, screenPos, canvas.worldCamera, out worldPos);
     return worldPos;
 }
开发者ID:inoook,项目名称:uGUICanvasTools,代码行数:8,代码来源:CanvasUtils.cs

示例8: GetCanvasRect

        public Rect GetCanvasRect(RectTransform t, Canvas c)
        {
            t.GetWorldCorners(m_WorldCorners);
            var canvasTransform = c.GetComponent<Transform>();
            for (int i = 0; i < 4; ++i)
                m_CanvasCorners[i] = canvasTransform.InverseTransformPoint(m_WorldCorners[i]);

            return new Rect(m_CanvasCorners[0].x, m_CanvasCorners[0].y, m_CanvasCorners[2].x - m_CanvasCorners[0].x, m_CanvasCorners[2].y - m_CanvasCorners[0].y);
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:9,代码来源:RectangularVertexClipper.cs

示例9: GetCanvasRect

 public Rect GetCanvasRect(RectTransform t, Canvas c)
 {
   if ((Object) c == (Object) null)
     return new Rect();
   t.GetWorldCorners(this.m_WorldCorners);
   Transform component = c.GetComponent<Transform>();
   for (int index = 0; index < 4; ++index)
     this.m_CanvasCorners[index] = component.InverseTransformPoint(this.m_WorldCorners[index]);
   return new Rect(this.m_CanvasCorners[0].x, this.m_CanvasCorners[0].y, this.m_CanvasCorners[2].x - this.m_CanvasCorners[0].x, this.m_CanvasCorners[2].y - this.m_CanvasCorners[0].y);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:10,代码来源:RectangularVertexClipper.cs

示例10: ShowStageComplete

    public static void ShowStageComplete(Canvas stageCompleteCanvas)
    {
        _stageComplete = stageCompleteCanvas.GetComponent<CanvasGroup>();

        Time.timeScale = 0;
        _stageComplete.alpha = 0xFF;
        _stageComplete.blocksRaycasts = true;

        //IsPaused = true;
    }
开发者ID:W0dan,项目名称:CaveDwellers_Unity,代码行数:10,代码来源:MenuManager.cs

示例11: Start

    // Use this for initialization
    void Start()
    {
        GameOverCanvas = GameOverCanvas.GetComponent<Canvas>();

        exitText = exitText.GetComponent<Button>();
        restartText = restartText.GetComponent<Button>();

        GameOverCanvas.GetComponent<Image>().enabled = false;
        exitText.gameObject.SetActive(false);
        restartText.gameObject.SetActive(false);
    }
开发者ID:hakr1337,项目名称:Ghost,代码行数:12,代码来源:GameOverScreen.cs

示例12: WorldToCanvasAnchoredPosition

    // http://answers.unity3d.com/questions/799616/unity-46-beta-19-how-to-convert-from-world-space-t.html
    // http://westhillapps.blog.jp/archives/44661739.html
    // http://docs.unity3d.com/ScriptReference/RectTransformUtility.ScreenPointToWorldPointInRectangle.html
    public static Vector2 WorldToCanvasAnchoredPosition(Vector3 pos, Canvas canvas, Camera viewCam)
    {
        Vector2 screenPos = RectTransformUtility.WorldToScreenPoint(viewCam, pos) * 1.0f / canvas.scaleFactor;
        RectTransform canvasRectT = canvas.GetComponent<RectTransform>();
        return screenPos - canvasRectT.sizeDelta / 2f;

        //		RectTransform canvasRectT = canvas.GetComponent<RectTransform>();
        //		Vector3 screenPos = viewCam.WorldToScreenPoint(pos);
        //		Vector2 worldPos = Vector2.zero;
        //		RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectT, screenPos, canvas.worldCamera, out worldPos);
        //		return worldPos;
    }
开发者ID:inoook,项目名称:uGUICanvasTools,代码行数:15,代码来源:CanvasUtils.cs

示例13: GetScreenPosition

    public Vector2 GetScreenPosition(Transform transform, Canvas canvas)
    {
        RectTransform canvasRect = canvas.GetComponent<RectTransform>();

        Vector2 viewportPosition = Camera.main.WorldToViewportPoint(transform.position);
       
        Vector2 world_screenPosition = new Vector2(
        ((viewportPosition.x * canvasRect.sizeDelta.x) - (canvasRect.sizeDelta.x * 0.5f)),
        ((viewportPosition.y * canvasRect.sizeDelta.y) - (canvasRect.sizeDelta.y * 0.5f)));
        world_screenPosition.y += healthbarOffset;

        return world_screenPosition;
    }
开发者ID:CliffordSix,项目名称:2.5Platformer,代码行数:13,代码来源:Damageable.cs

示例14: StartMinigame

 public void StartMinigame()
 {
     if (!hacking) {
         if (questLog.DoesHaveQuest (questName)) {
             Debug.Log ("Player Has Quest");
             hacking = true;
             clone = Instantiate (hackingMinigame);
             clone.GetComponent<HackingGameScript> ().sg = gameObject.GetComponent<StartGame> ();
             clone.transform.position = new Vector3 (0, 0, 0);
         } else if (!questLog.DoesHaveQuest (questName)) {
             Debug.Log ("Player either does not have Quest, or the Quest has previously been completed.");
         }
     }
 }
开发者ID:abittman,项目名称:15T3GamesStudio2,代码行数:14,代码来源:StartGame.cs

示例15: Start

    // Use this for initialization
    void Start()
    {
        parentCanvas = GetComponent<Canvas>();
        deadmau5Audio = parentCanvas.GetComponent<AudioSource> ();
        StopMusic();

        if (parentCanvas.worldCamera != Camera.main)
            parentCanvas.worldCamera = Camera.main;

        uiImage = GetComponentInChildren<Image>();

        uiImage.sprite = images[0];

        StartCoroutine(CycleImages());
    }
开发者ID:yoe32,项目名称:Proyecto-4,代码行数:16,代码来源:Splash.cs


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