Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Dec 2006
Offline Last Active Apr 18 2014 12:59 PM

Posts I've Made

In Topic: How to set camera to maximize the mesh view into the screen?

11 April 2014 - 12:40 PM

Couple of ways of doing this, both need to know the size of the mesh.


So you need to first generate a bounding box or a bounding sphere. (there are lots of online resources to help you with this)


Then you can either ...


1) Move the camera forward until the mesh fills the screen.


     To work out the distance to place the camera you calculate distance = bounding_sphere.radius / tan(field_of_view)


2) You change the field of view in your projection matrix 


     To work out the field of view required you calculate fov = atan(bounding_sphere.radius/camera_distance)


Both might need a little adjustment , but it's a good starting point.



Personally, I like changing the distance of the camera approach.  Messing with the FOV too much also messes with perspective.  And sometimes that's just plain funny looking.

In Topic: First Android Game

11 April 2014 - 07:56 AM

Small bug there in main menu.

If I click "Play" while board is in transition state (I just clicked right or left), then Play button will stuck in pressed state and will do nothing until app restarted.


Ahhh,  I see that.  Thank you so much.  Will get that fixed right away!!!!


Edit:  Fixed and now I hide the next button if there is no next environment and the same with the previous button.

In Topic: A Collaborative Free and Open-Source OS?

08 April 2014 - 08:57 AM

Why can't people just leave this kid alone? 


Then these threads can at least have a chance to maintain some semblance of coherence.

In Topic: using a graphical icon as a button

08 April 2014 - 07:46 AM



OnMouseOver works but is called every frame that the mouse is over the object.  There is also OnMouseEnter and OnMouseExit to simulate Hover events (each only called one time when the action is observed).  You could do something like this in C#.

using UnityEnging;
using System.Collections;

public class ButtonController : MonoBehaviour{

	// set via the inspector
	public Texture2D hoverTexture = null;
	// cached components
	private GUITexture myGUITexture = null;
	private Texture2D defaultTexture = null;
	// SceneManager is a singleton - see Scripting Reference for
	// FindObjectOfType for a hint on how to implement
	private SceneManager scene = null;	
	void Start(){
		scene = SceneManager.Instance;
		myGUITexture = GetComponent<GUITexture>();
		defaultTexture = (Texture2D) myGUITexture.texture;
	void OnMouseEnter(){
		myGUITexture.texture = hoverTexture;
	void OnMouseExit(){
		myGUITexture.texture = defaultTexture;
	void OnMouseUpAsButton(){
		// SceneManager defines a funciton that takes a string and depending on 
		// which button is pressed it takes a different action.
		// this way all of your button logifc is in one component and you can have
		// a single button script instead of each button needing it's own script logic.

Also, you should note that you are not limited to using GuiTextures/GuiText as buttons.  This is considered the "Legacy" GUI system by Unity.  Check the references for GUI.  I must admit that I do happen to like the legacy system more for things just like simple image buttons and labels, but if you need more complex controls (sliders, dialogboxes, input controls, etc) then you should use the GUI class.  Check the scripting reference.


Believe it or not, you don't need to use either of those if you don't want to.  Any object in the game that has a collider can override the functions in the script above so you can use 3DText, a character, etc as a button.   Instead of changing the texture you could offset it towards the camera to make it bigger, you could have it enter an animation sequence, you could have it change pose, etc.  The script is almost the same other than that.


Hope this helps.

In Topic: Learning Unity

03 April 2014 - 01:44 PM

A while back Game Institute was having a great deal on their full course enrollment. Something like $49.  I went for it.  They have a section on unity with about 20 videos.  I find them full of great information.  You may want to check it out.