Website may be up and down over next few months. I'm currently doing a complete overhaul of everything. Going back to simple individual .htm pages, new overall site theme, sanitizing and cleaning up html of all pages and blog posts, attempting to implement a new tooling and publishing system etc etc.

To allow the user to undo actions that are performed by a custom editor script you can use Undo.RegisterUndo

foreach (var item in Selection.transforms)
{
    Undo.RegisterUndo(item, "Move " + item.name);
    var pos = item.position;
    pos = new Vector3(activeObject.transform.position.x, pos.y, pos.z);
    item.transform.position = pos;
}

If you want to take advantage of functionality that is provided my menu commands you can use EditorApplication.ExecuteMenuItem in your editor scripts to execute them.


Are you working on a large project but dislike how many objects you have to weed through in the hierarchy window? You can create editor scripts that change the objects Object.hideFlags property to hide or show the object in the hierarchy window.

var item = Selection.activeGameObject;
if ((item.hideFlags & HideFlags.HideInHierarchy) == HideFlags.HideInHierarchy)
{
                item.hideFlags = item.hideFlags ^ HideFlags.HideInHierarchy;
                item.active = !item.active;
                item.active = !item.active;
}

Notice that item.active = !item.active is specified twice. Currently in unity 3.5 you need those 2 lines of code for the game object to hide and show properly in the hierarchy window.


Wondering how to save player preferences across sessions or save settings for an editor script to use? Check out EditorPrefs & PlayerPrefs.


If you are writing custom editors for unity and you need to have a way of editing the tools settings you can have those settings show up in the Unity Preferences Window "Edit -> Preferences...".

Just create a new editor script that has a public class and add the fallowing lines of code ...

// Add preferences section named "cbxTools" to the Preferences Window
    [PreferenceItem("cbxTools")]
    public static void PreferencesGUI()
    {
        // Preferences GUI
        cbxToolPreferencesConfig.Instance.DrawGUI();
    }


If you are creating custom editors for unity but only want the gui for that editor to be drawn in the currently active scene view try this ...    

if (SceneView.mouseOverWindow.GetInstanceID() == SceneView.currentDrawingSceneView.GetInstanceID())
        {
            this.DrawGUI(SceneView.currentDrawingSceneView);
        }

If your suddenly finding that Unity will instanty terminate while running your code, check if you are invoking any infinite recusion loops. This has recently happened to me and it was a bit of a pain to track down with Unity 3.5 instantly terminating. Hopfully the Unity team will handle the infinite recustion issue in a future version.


You can visually tag your game objects with icons by selecting the object and clicking the Red/Green/Blue colored cube in the upper left of the inspector window.

You can select a colored Label, Dot, or a Texture from your assets.


I have still been learning the in and outs of Unity for the past few weeks. I've been thinking that because I have not been making any regular posts on this site that I would start posting a series of quick unity tips as I learn of them.

Tip #1 - Prevent config dialog from showing when running your compiled game.

When you build your unity game using "File -> Build & Run" and then run the *.exe that was generated you will see a dialog pop up.

To prevent the configuration window from being shown select "File -> Build Settings..." in unity and click the "Player Settings" button at the bottom of the window. The Unity inspector window will contain a number of options. Find the drop down titled "Display Resolution Dialog" and set it to "Disabled". Rebuild your game and run the generated *.exe. No more dialog pop up!


Unity, Deleted posts, and updates

Published 4/27/2012 by createdbyx in News
Tags:

I have been working on working on a few things these past few weeks. First is that I am in the process of redesigning the www.createdbyx.com website with my own custom built MVC like solution. This will provide me with a familiar MVC coding experience but in a extremely simplified and lightweight manner.It will also be built around System.IO.Stream so it should be able to run on almost anything not just asp.net.

Second thing is that I have come back to learning about the Unity game engine. It can be a real pain learning a new platform some times. I find myself having difficulties doing the simplest of things, but I know that eventually with more experience it will become child's play.

I also deleted my previous post titled "Guilty!". I deleted it because the video was from Break.com and apparently the video is no longer available. This is why I hate linking to crap in the internet. Links are fickle and websites change too often.

I have not posted too many updates lately on this site as I simply have not had the motivation to do so. Maybe when I start doing more with Unity I will post more on that.


Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume