[Freebie] Instantiate GameObject Reference

Options
Hey!
Are you fed up with typing in paths to objects you want to network instantiate? Me too!
Here's a really simple little class/ property drawer that will allow you to directly reference the objects you want to instantiate :)

zEUVdJO.png

It even goes red when the object you reference is outside of the Resources/ folder!
Simply reference .gameobjectLocation whenever you want to network instantiate the object :)

Class
[System.Serializable]
public class ReachNetworkObject
{
    public GameObject gameobject;
    public GameObject lastGameobject;
    public string gameobjectLocation;
}

Property Drawer
[CustomPropertyDrawer(typeof(ReachNetworkObject))]
public class ReachNetworkObjectDrawer : PropertyDrawer
{
    string resourcePath = "Assets/Resources/";

    private string GetAssetLocation(Object asset)
    {
        if (asset != null)
        {
            string assetPath = AssetDatabase.GetAssetPath(asset);


            if (assetPath.Contains(resourcePath))
            {
                return assetPath.Substring(resourcePath.Length).Split(new char[] {'.'})[0];
            }
            else
            {
                Debug.LogError("GameObject is not inside resources folder! Network objects must be!");
            }
        }

        return "";
    }

    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        SerializedProperty gameobject = prop.FindPropertyRelative("gameobject");
        SerializedProperty lastGameobject = prop.FindPropertyRelative("lastGameobject");
        SerializedProperty gameobjectLocation = prop.FindPropertyRelative("gameobjectLocation");

        if (gameobject.objectReferenceValue != lastGameobject.objectReferenceValue)
        {
            gameobjectLocation.stringValue = GetAssetLocation(gameobject.objectReferenceValue);
            lastGameobject.objectReferenceValue = gameobject.objectReferenceValue;
        }

        Color original = GUI.color;
        if (gameobjectLocation.stringValue == "")
        {
            GUI.color = Color.red;
        }

        EditorGUI.PropertyField(
                new Rect(pos.x, pos.y, pos.width, pos.height),
                gameobject,
                new GUIContent(label));

        GUI.color = original;
    }
}