background preloader

Unity3D Reference

Facebook Twitter

Unity: make your lists functional with ReorderableList. In Unity 4.5 we got a nice (undocumented) built-in tool to visualize lists in IDE.

Unity: make your lists functional with ReorderableList

It's called ReorderableList, it's located in UnityEditorInternal namespace and looks like this: Let's see how to code this beautiful interface in Unity IDE using ReorderableList. Note: Though UnityEditorInternal namespace is public, it seems to be intended for Unity Team internal use (hence the name), it is not documented and might change in future versions of Unity.

If you notice an API change please post it in comments section below. Sources: Project sources are on GitHub. Setting up the project Let's pretend that we are making a Tower Defense-like game and need a decent interface for our game-designer to set up waves of monsters for a particular level. First, create a new Unity project.

We will need some test assets: mobs and bosses. Storing data Create Scripts folder where we will store our C# scripts. Add this code to MobWave.cs. As you see, every wave can be either a wave of Mobs or one or more Bosses. (Saving...) (Saving...) Unity 3D Best Practices: Physics. (Note: This is a follow-up post to a previous article on optimisations and best practices for Unity development).

(Saving...) (Saving...) Unity 3D Best Practices: Physics

This second part in our series will be entirely focused on Unity’s Physics engines. I’ll present, similarly to the previous article, simple topics which are easy to use and will optimise the physics engine usage. Let’s begin! All game objects, if not configured, are created on the Default layer where (by default) everything collides with everything. This is quite inefficient. Establish what should collide with what. For each new layer, a new row and column is added on the Collision Matrix. By default, when adding a new layer, the Collision Matrix is set for that new layer to collide with every other existing one, so it’s the developer’s responsibility to access it and setup its interactions. By correctly setting layers and setting up your Collision Matrix, you will avoid unnecessary collisions and testing on collision listeners. Figure 1 : Collision Matrix config. Stack Overflow. Unity Answers. 50 Tips for Working with Unity (Best Practices)

About these tips (Edit: August 2016.

50 Tips for Working with Unity (Best Practices)

I have revised these tips. You can find the new list here.) These tips are not all applicable to every project. They are based on my experience with projects with small teams from 3 to 20 people.There’s is a price for structure, re-usability, clarity, and so on — team size and project size determine whether that price should be paid.Many tips are a matter of taste (there may be rivalling but equally good techniques for any tip listed here).Some tips may fly in the face of conventional Unity development. Process 1. 2. 3. 4. It makes it unnecessary to re-setup each scene.It makes loading much faster (if most objects are shared between scenes).It makes it easier to merge scenes (even with Unity’s new text-based scenes there is so much data in there that merging is often impractical in any case).It makes it easier to keep track of data across levels.

You can still use Unity as a level editor (although you need not). Unity - Unity Manual. UNITY: Documentation. Unity - Game Engine. Common Unity Gotchas. There are a number of "gotchas" that hit pretty much everyone new to Unity programming.

Common Unity Gotchas

Sometimes these are due to you being new to programming in general, and sometimes it's due to the fact that Unity uses a slightly unusual method of attaching multiple scripts to a game object. This overview tries to take you through the ones we see most often on Unity Answers. The Gotchas How to access a variable or method on another script or object How to access a variable or method on another script or object There is also a really great tutorial and video on GetComponent which you can read and watch in C# or in UnityScript So you've written two scripts and you want to access variables or methods on one script from the other one, but you can't quite work out how to get a reference to the script or how to get the variable.

You may be tempted to declare variables as static so that you can access them easily without having to actually reference the object on which the script is placed.