Beispiel #1
0
 public override object OnGUI(GUIContent content, object instance)
 {
     if (attribute.options != null)
     {
         return(EditorUtils.Popup <object>(content, instance, attribute.options.ToList()));
     }
     return(MoveNextDrawer());
 }
 public override object OnGUI(GUIContent content, object instance)
 {
     if (attribute.options != null && attribute.options.Length > 0)
     {
         var optType = attribute.options[0].GetType();
         if (fieldInfo.FieldType.IsAssignableFrom(optType))
         {
             return(EditorUtils.Popup <object>(content, instance, attribute.options));
         }
     }
     return(MoveNextDrawer());
 }
Beispiel #3
0
        public override object OnGUI(GUIContent content, object instance)
        {
            var targetField = context.GetType().GetField(attribute.fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (targetField != null)
            {
                var fieldValue = targetField.GetValue(context);
                if (fieldValue is BBParameter)
                {
                    fieldValue = ((BBParameter)fieldValue).value;
                }
                List <object> options  = new List <object>();
                object        selected = instance;
                if (instance is BBParameter)
                {
                    selected = ((BBParameter)instance).value;
                }
                if (fieldValue is Material)
                {
                    foreach (var name in ((Material)fieldValue).GetTexturePropertyNames())
                    {
                        options.Add(name);
                    }
                    if (instance is BBParameter)
                    {
                        ((BBParameter)instance).value = EditorUtils.Popup(content, selected, options);
                        return(instance);
                    }
                    return(EditorUtils.Popup(content, selected, options));
                }
                else if (fieldValue is Renderer)
                {
                    foreach (var name in ((Renderer)fieldValue).materials.Select(x => x.GetTexturePropertyNames()))
                    {
                        options.AddRange(name);
                    }
                    if (instance is BBParameter)
                    {
                        ((BBParameter)instance).value = EditorUtils.Popup(content, selected, options);
                        return(instance);
                    }
                    return(EditorUtils.Popup(content, selected, options));
                }
            }
            return(MoveNextDrawer());
        }