How do Property Drawer?

in above example,

[Popup ("Warrior", "Mage", "Archer", "Ninja")]
    public string @class = "Warrior";   
 [Popup ("Human/Local", "Human/Network", "AI/Easy", "AI/Normal", "AI/Hard")] 
public string controller;

[Popup(…)] doesn’t work.

says, namespace doesn’t have popup.

Just spent few hours looking for working examples also (for c#…not much luck)

but couple blogs had few examples (collected/-ing links here),

So eventually what scripts should be made and where put? Editor folder? what script?

And how it can possible simple mechanic as unity official blog?

Why unity so suck at document there is no such example like unity blog and there is none c# example?

There is a good example here:

It is not c# example and none of script input position and structure, name.

I am not sure what you mean by “none of script input position and structure, name.”

The C# version is almost the same as the UnityScript which is demonstrated :wink:

I have not tested the following, but I have converted one of the simpler examples from UnityScript to C# for you. I hope that this helps :slight_smile:

// Assets/Scripts/RangeAttribute.cs
using UnityEngine;

public class RangeAttribute : PropertyAttribute {
	public float min;
	public float max;
	
	public RangeAttribute (float min, float max) {
		this.min = min;
		this.max = max;
	}
}


// Assets/Scripts/Editor/RangeDrawer.cs
using UnityEngine;
using UnityEditor;

// The property drawer class should be placed in an editor script, inside a folder called Editor.
// Tell the RangeDrawer that it is a drawer for properties with the RangeAttribute.
[CustomPropertyDrawer (typeof(RangeAttribute))]
public class RangeDrawer : PropertyDrawer {
	
	// Draw the property inside the given rect
	public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
		
		// First get the attribute since it contains the range for the slider
		RangeAttribute range = attribute as RangeAttribute;
		
		// Now draw the property as a Slider or an IntSlider based on whether it's a float or integer.
		if (property.propertyType == SerializedPropertyType.Float)
			EditorGUI.Slider (position, property, range.min, range.max, label);
		else if (property.propertyType == SerializedPropertyType.Integer)
			EditorGUI.IntSlider (position, property, range.min, range.max, label);
		else
			EditorGUI.LabelField (position, label.text, "Use Range with float or int.");
	}
}


// Assets/Scripts/CustomBehaviour.cs
using UnityEngine;

public class CustomBehaviour : MonoBehaviour {
	[Range(0f, 10f)]
	public float someRange;
}

I never thought it is possible that class name can be without derived from : Monobehavior

well, thanks and this works well,

(except revise like this)
EditorGUI.InsSlider(position, property, (int)range.min, (int)range.max, label);

then, how about other examples like [[Multiline]], [Compact]?

So this feature is not internally already done, should I input code all for [Multiline], etc…?

Then where can I find other example?