@ -221,26 +221,11 @@ namespace Fungus.EditorUtils
var origLabel = new GUIContent ( label ) ;
if ( EditorGUI . GetPropertyHeight ( valueProp , label ) < = EditorGUIUtility . singleLineHeight )
{
DrawSingleLineProperty ( position , origLabel , referenceProp , valueProp , flowchart , typeInfo ) ;
}
else
{
DrawMultiLineProperty ( position , origLabel , referenceProp , valueProp , flowchart , typeInfo ) ;
}
EditorGUI . EndProperty ( ) ;
}
protected virtual void DrawSingleLineProperty ( Rect rect , GUIContent label , SerializedProperty referenceProp , SerializedProperty valueProp , Flowchart flowchart ,
VariableInfoAttribute typeInfo )
{
int popupWidth = Mathf . RoundToInt ( EditorGUIUtility . singleLineHeight ) ;
const int popupGap = 5 ;
//get out starting rect with intent honoured
Rect controlRect = EditorGUI . PrefixLabel ( rect , l abel) ;
Rect controlRect = EditorGUI . PrefixLabel ( position , origLabel ) ;
Rect valueRect = controlRect ;
valueRect . width = controlRect . width - popupWidth - popupGap ;
Rect popupRect = controlRect ;
@ -251,64 +236,15 @@ namespace Fungus.EditorUtils
if ( referenceProp . objectReferenceValue = = null )
{
DrawValueProperty ( valueRect , valueProp , typeInfo ) ;
CustomVariableDrawerLookup . DrawCustomOrPropertyField ( typeof ( T ) , valueRect , valueProp ) ;
popupRect . x + = valueRect . width + popupGap ;
popupRect . width = popupWidth ;
}
EditorGUI . PropertyField ( popupRect , referenceProp , new GUIContent ( "" ) ) ;
EditorGUI . indentLevel = prevIndent ;
}
protected virtual void DrawMultiLineProperty ( Rect rect , GUIContent label , SerializedProperty referenceProp , SerializedProperty valueProp , Flowchart flowchart ,
VariableInfoAttribute typeInfo )
{
const int popupWidth = 1 0 0 ;
Rect controlRect = rect ;
Rect valueRect = controlRect ;
valueRect . width = controlRect . width - 5 ;
Rect popupRect = controlRect ;
if ( referenceProp . objectReferenceValue = = null )
{
DrawValueProperty ( valueRect , valueProp , typeInfo ) ;
popupRect . x = rect . width - popupWidth + 5 ;
popupRect . width = popupWidth ;
}
else
{
popupRect = EditorGUI . PrefixLabel ( rect , label ) ;
}
EditorGUI . PropertyField ( popupRect , referenceProp , new GUIContent ( "" ) ) ;
}
protected virtual void DrawValueProperty ( Rect valueRect , SerializedProperty valueProp , VariableInfoAttribute typeInfo )
{
CustomVariableDrawerLookup . DrawCustomOrPropertyField ( typeof ( T ) , valueRect , valueProp ) ;
}
public override float GetPropertyHeight ( SerializedProperty property , GUIContent label )
{
VariableInfoAttribute typeInfo = VariableEditor . GetVariableInfo ( typeof ( T ) ) ;
if ( typeInfo = = null )
{
return EditorGUIUtility . singleLineHeight ;
}
string propNameBase = typeInfo . VariableType ;
propNameBase = Char . ToLowerInvariant ( propNameBase [ 0 ] ) + propNameBase . Substring ( 1 ) ;
SerializedProperty referenceProp = property . FindPropertyRelative ( propNameBase + "Ref" ) ;
if ( referenceProp . objectReferenceValue ! = null )
{
return EditorGUIUtility . singleLineHeight ;
}
SerializedProperty valueProp = property . FindPropertyRelative ( propNameBase + "Val" ) ;
return EditorGUI . GetPropertyHeight ( valueProp , label ) ;
EditorGUI . EndProperty ( ) ;
}
}