本文整理汇总了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;
}
示例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);
}
}
示例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();
}
}
示例4: InitGameplayController
public void InitGameplayController(Canvas p_UICanvas)
{
ui_Canvas = p_UICanvas;
uiCanvasRect = ui_Canvas.GetComponent<RectTransform>();
UpdateBuildButton();
DisableBuildButton();
}
示例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>();
}
示例6: Start
// Use this for initialization
void Start ()
{
canvas = GameObject.FindObjectOfType<Canvas>();
sceneManager = canvas.GetComponent<csBedroomSceneManager>();
kagotchi = GameObject.Find("Kagotchi");
on = true;
}
示例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;
}
示例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);
}
示例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);
}
示例10: ShowStageComplete
public static void ShowStageComplete(Canvas stageCompleteCanvas)
{
_stageComplete = stageCompleteCanvas.GetComponent<CanvasGroup>();
Time.timeScale = 0;
_stageComplete.alpha = 0xFF;
_stageComplete.blocksRaycasts = true;
//IsPaused = true;
}
示例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);
}
示例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;
}
示例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;
}
示例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.");
}
}
}
示例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());
}