background preloader

Unity3D

Facebook Twitter

Newbie guide to Unity Javascript (long) Font. Switch to Scripting Fonts can be created or imported for use in either the GUI Text or the Text Mesh Components.

Font

Importing Font files To add a font to your project you need to place the font file in your Assets folder. Unity will then automatically import it. Supported Font formats are TrueType Fonts (.ttf files) and OpenType Fonts (.otf files). To change the Size of the font, highlight it in the Project View and you have a number of options in the Import Settings in the Inspector. Import Settings specific to dynamic fonts After you import the font, you can expand the font in Project View to see that it has auto-generated some assets. Dynamic fonts When you set the Characters drop-down in the Import Settings to Dynamic, Unity will not pre-generate a texture with all font characters. Note that some target platforms (WebGL, some consoles) do not have OS default fonts Unity can access for rendering text.

Custom fonts To create a custom font select ‘Create->custom font’ from the project window. Changing Text Size Relative To Screen? Here's one I wrote that changes mostly in realtime in the editor so you can place before running.

Changing Text Size Relative To Screen?

Just toggle Maximize on Play to get the actual change if you aren't seeing it. 1. Create a C# script called ScaleFont 2. Paste in this code 3. Drop the script on your GUIText 4. Set your font size as a base and the ratio will scale from there.Code (csharp):using UnityEngine;using System.Collections;[ExecuteInEditMode] public float ratio = 10; // Use this for initialization } // Update is called once per frame }float finalSize =(float)Screen.width/ratio; }} GUI.TextField. Static function TextField (position : Rect , text : String , maxLength : int , style : GUIStyle ) : String Parameters Returns String - The edited string.

GUI.TextField

Description Make a single-line text field where the user can edit a string. JavaScript JavaScript C# Boo var stringToEdit : String = "Hello World" ; function OnGUI () { stringToEdit = GUI.TextField ( Rect (10, 10, 200, 20), stringToEdit, 25); } using UnityEngine; using System.Collections; public class example : MonoBehaviour { public string stringToEdit = "Hello World" ; void OnGUI () { stringToEdit = GUI.TextField ( new Rect (10, 10, 200, 20), stringToEdit, 25); } } Is it possible to have multiple tags (or the like) on one object. A* Pathfinding Project. Vector3.Lerp. Vector3.Lerp static function Lerp(from: Vector3, to: Vector3, t: float): Vector3; Description Linearly interpolates between two vectors.

Vector3.Lerp

Interpolates between from and to by the fraction t. Unity 2D Platform Controller v0.1. Mike’s Unity Scripting Tutorial. Unity keyboard control for move & turn Now let’s learn scripting by looking at basic scripts for controlling a cube we’ve made.

Mike’s Unity Scripting Tutorial

Here’s a sample that uses the user’s choice of fwd/bkwd keys for movement and their left/right keys for turning. (Keys are defined in menu “Edit:Project Settings:Input”) Create this script and add it to a visible cube. (You definitely want to move the camera while editing so that the cube is visible when you start playing.) Beware: this copies and pastes well from SAFARI but has trouble with line endings when copied from Firefox (Firefox versions 3 through 16 ignore the unix “LF” linefeeds that I use in this unicode web page).Beware: integer math kills rotations.Beware: editing a script might not change copies of the script that are already attached to game objects, so I’ve been pressing "reset" on the attached script in the inspector.

Here is a move_force script that allows your player to accelerate and twist. 46 Tips & Tricks for 2D mobile Performance in Unity. If this is your first jump into the world of Unity, my first tip (this one’s a freebie) is to stop trying to use it like other languages and environments.

46 Tips & Tricks for 2D mobile Performance in Unity.

You will be using GameObjects, you will be adding multiple script components, and you will have to think differently. Unity. Apple Developer. Editing Unity’s Editor - Size Five Games. Following last week’s post about how we’re handling trendy-looking 2D in Unity3D, I had a few requests for a bit more info on what we’re doing Editor-side.

Editing Unity’s Editor - Size Five Games

Here’s Tim again, explaining what on Earth he’s been up to: We use Unity Editor extensions for lots of things, The Transform2D Inspector is an example of one we use to customise the editor to work better in a 2D game. It overrides Unity’s default Transform Inspector for object that have a Toolkit2D Sprite component attached. It simply cuts away all the information we don’t need for a 2D game; for example, we never have to rotate something on the x or y axis… it just doesn’t make sense in 2D, so we hide that data away and only show the z rotation, which the inspector surfaces as ‘Rotation’. The Enable Snapping Checkbox turns on our snapping tool. We also use Editor extentions for data entry.

Unity defaults to showing the whole list in a tree view, which is confusing to say the least. Unity - Game Engine.

Tutorials