Twisted Potions Double Trouble / Assets / Scripts / GUIManager.cs

using UnityEngine;
using System.Collections;

public class GUIManager : MonoBehaviour
	public enum GuiAnchor
	public int offset = 0;
	public GuiAnchor anchor = GuiAnchor.bottomLeft;
	void Awake ()
		// Let's remove the UI on desktop versions
		// Later versions will only remove the iphone ui not all
		// To place this current gui layer on its correct position we'll 
		// check the camera current 0,0 and set it there.
		// It is neccesary that the gui objects are always placed under a camera
		// Since it server for 2 purposes:
		// a) The gui moves along with it as it's parented. 
		// b) It uses it to relocate to it's 0,0
		Camera camera =;
		switch (anchor) {
			case GuiAnchor.bottomLeft:	
				Vector3 zeroPoint = camera.ViewportToWorldPoint (;
				zeroPoint.z = gameObject.transform.position.z;
				zeroPoint.x += offset;
				gameObject.transform.position = zeroPoint;			
			case GuiAnchor.bottomRight:	
				Vector3 onePoint = camera.ViewportToWorldPoint (new Vector3(1,0,0));
				onePoint.z = gameObject.transform.position.z;
				onePoint.x += offset;
				gameObject.transform.position = onePoint;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.