{I+=codeWee;}
[Unity3d] Custom Inspector for Script
=== Script ===

using UnityEngine;
using System.Collections;

public class SampleScript : MonoBehaviour {

    public Vector3 TranslateValue;

    public void Move()
    {
        transform.Translate(TranslateValue);
    }
}

=== Custom Inspector ===
(Following file must be in "Editor" folder under the "Assets" folder)

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(SampleScript))]
public class SampleEditor : Editor
{
    public override void OnInspectorGUI()
    {
        SampleScript target = base.target as SampleScript;
        GUILayout.Space(10f);
        target.name = EditorGUILayout.TextField("Name", target.name, new GUILayoutOption[0]);
        target.TranslateValue = EditorGUILayout.Vector3Field("Translation Value", target.TranslateValue, new GUILayoutOption[0]);

        GUILayout.Space(10f);

        if (GUILayout.Button("Move", new GUILayoutOption[0]))
        {
            target.Move();
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(base.target);
        }
    }
}
HTML | PHP | C++ | DirectX11 | Javascript | C# | HTML5 | ASP | SQL | General | CSS | Oculus Rift | Unity3d | Virtools SDK | Tip | NSIS | PowerShell | node.js | Web API | RTSP | All
Copyright© 2016 CodeWee.com All rights reserved.