• SambaLinkMaker

    Hi there! This weekend I hacked together a little tool to convert local paths to UNC or samba links you can share with your buddies on LAN. Mostly so I have something to blog about, but it may just as well make my life easier ;)

    You can grab it from github. Note that there is at least one such program for Windows already, I use Linux so I made it Windows/Linux cross platform.

  • Unity3D: keeping asset sources in the tree

    It’s advisable to keep source files for the assets (ex.: .ps, .max, .blend) near the final ones you actually want Unity to import because it’s a lot easier to keep things organized this way and work with Version Control Systems. Folks will tell you to keep a mirror structure outside of assets folder, which is the exact opposite.

    Do not want!

    So here’s the trick: Unity doesn’t import files and folders that are hidden or have the name starting with a dot. Naming files with a starting dot is better in my opinion. Git for example doesn’t store the hidden attribute, and other VCSes probably don’t as well.

    You can do something like this:

    .monkey.max         <- source file, not imported
    monkey.fbx          <- imported normally
    .monkey_diffuse.psd <- source file, not imported
    monkey_diffuse.png  <- imported normally

    or

    monkey.fbx         <- imported normally
    monkey_diffuse.png <- imported normally
    .source            <- entire folder not imported
    .source/monkey.max
    .source/monkey_diffuse.psd

    The second structure can be better with many files. Windows explorer won’t let you name a directory this way though (THANK YOU MICROSOFT!). Create or rename it and write “.source.” (with final dot added), it will name it “.source” stripping the final dot. Tested on Windows 7, don’t ask me why it’s like this.

    Hopefully it will save you some headaches.

  • Quick post: Unity editor wrapper

    I’ve seen people reverse engineer the transform editor or doing their own thing. In Unity 4 you can render the original editor inside yours as long as you have the original editors type.
    Here’s an example for a transform editor wrapper, but you can wrap anything you want, like a MeshRenderer or a TextureImporter (haven’t tried yet).
    You may want to wrap other Editor methods besides OnInspectorGUI as well.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    using UnityEngine;
    using UnityEditor;
    
    [CustomEditor(typeof(Transform))]
    public class TransformEditorWrapper : Editor {
    	Editor transformEditor;
    	
    	void OnEnable() {
    		Transform transform = target as Transform;
    		System.Type t = typeof(UnityEditor.EditorApplication).Assembly.GetType("UnityEditor.TransformInspector");
    		transformEditor = Editor.CreateEditor(transform, t);
    	}
    	
    	public override void OnInspectorGUI() {
    		GUI.changed = false;
    		transformEditor.OnInspectorGUI();
    
    		Transform transform = target as Transform;
    		GUILayout.Label("WRAPPED!");
    		// do your stuff here...
    	}
    	
    	void OnDisable() {
    		DestroyImmediate(transformEditor);
    	}
    }