Hallo,
ich habe das hier mal ausprobiert jedoch ist dann im Inspector Window kein Editor Design zu sehen sondern die normalen public Variablen...
http://docs.unity3d.com/ScriptReference/Editor.html
Mein Code:
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class StatsController : MonoBehaviour {
public int health;
public int damage;
}
#if UNITY_EDITOR
[CustomEditor(typeof(StatsControllerEditor))]
public class StatsControllerEditor : Editor {
public override void OnInspectorGUI() {
StatsController mp = (StatsController)target;
mp.damage = EditorGUILayout.IntSlider("Damage", mp.damage, 0, 100);
ProgressBar(mp.damage / 100.0f, "Damage");
bool allowSceneObjects = !EditorUtility.IsPersistent(target);
}
// Custom GUILayout progress bar.
void ProgressBar(float value, string label)
{
// Get a rect for the progress bar using the same margins as a textfield:
Rect rect = GUILayoutUtility.GetRect(18, 18, "TextField");
EditorGUI.ProgressBar(rect, value, label);
EditorGUILayout.Space();
}
}
#endif
Ich habe 2 Fragen dazu,
1. Warum funktioniert das nicht wie im Tutorial?
2. Der Script wird ja mit exportiert brauch ich da die if Editor Schleifen oder kann ich die weglassen?