Comments (8)
Hope this is not off topic:
Only an incomplete solution, but I managed to get Attributes working in my custom editor by using NaughtyAttributes.InspectorEditor as base class. Only thing is that I needed to make InspectorEditor.OnEnable "protected virtual" so I could override.
In my custom editor I override OnInspectorGUI and do what I need after base.OnInspectorGUI().
from naughtyattributes.
Fixed in version 2.0.0.
The attributes are now reimplemented with Unity's CustomPropertyDrawer so they work in custom inspectors. There are some exceptions, however (like ReorderableList, EnableIf...). For these to work you need to call NaughtyEditorGUI.PropertyField_Layout
instead of EditorGUILayout.PropertyField
when you are creating your custom editors
from naughtyattributes.
I have to check that out mate, but I don't think it's possible at the moment. The problem is that I am not using the Unity's API to create custom attributes (if I was this issue wouldn't have happened). There were some limitations, and I decided to create my own API for creating attributes. I need to think of a fix, because your case is a very common thing.
from naughtyattributes.
The way I usually use this in a Custom Inspector is something like this:
void OnEnable()
{
...
prop = serializedObject.FindProperty("prop");
...
}
public override void OnInspectorGUI()
{
...
EditorGUILayout.PropertyField(prop);
...
}
So I'd be fine with doing something like:
public override void OnInspectorGUI()
{
...
NaughtyAttributes.GUILayout.PropertyField(prop);
...
}
If that's easier to get working. Just as long as there's some way to get the custom drawing from a Custom Inspector, it doesn't have to be via EditorGUILayout.PropertyField()
.
from naughtyattributes.
Well, I am using EditorGUILayout.PropertyField(property, includeChildren) for drawing the properties, but not for all attributes. The ReorderableList for example uses some stuff from the UnityEditorInternal namespace. I need to see what exactly is the problem here, but I like your advice with the NaughtyAttributes.GUILayout.PropertyField(prop).
from naughtyattributes.
The first Attribute I used and the one I had problems with was ShowIf
- it could be that some of the others work fine and that just happens to be one of the ones that doesn't.
from naughtyattributes.
Hope this is not off topic:
Only an incomplete solution, but I managed to get Attributes working in my custom editor by using NaughtyAttributes.InspectorEditor as base class. Only thing is that I needed to make InspectorEditor.OnEnable "protected virtual" so I could override.
In my custom editor I override OnInspectorGUI and do what I need after base.OnInspectorGUI().
This works, although it would be helpful to mark OnEnable and OnDisable as protected virtual, so that they can be overriden in inheriting inspectors.
from naughtyattributes.
This problem still exists when making a custom editor like the latest answer by BgBg in this link: http://answers.unity.com/answers/1904868/view.html
[ReadOnly] and [ShowIf] attributes dont draw as expected. And the editor doesnt contain any of the property field stuff as in the last comment above ^
from naughtyattributes.
Related Issues (20)
- [Request] AnimatorState Attribute HOT 1
- [AllowNesting] won't find CustomPropertyDrawers... and how I fixed it. HOT 1
- [Bug] Error "Unsupported type Vector2f" when editing Vector2 value in inspector HOT 1
- [Request] Clicking a button on multiple objects only clicks one
- Using NaughtyAttributes hides inspector tools for custom audio filters (OnAudioFilterRead) HOT 1
- [BUG] [ShowIf] with [AllowNesting] doesn't work for String values if put after a [TextArea] attribute
- GC allocs for rendering HOT 1
- Many attributes do not work in Unity 2022.2+ HOT 13
- Can't add generic script on object HOT 1
- (bug) Excessive Spacing with the ShowIf/HideIf attributes in Nested Arrays HOT 1
- Boxgroups do not display background on List<T> types
- [Request] Foldouts and BoxGroups should give a List<T> type a bit of an indent for readability
- [Request] Add enum support to "EConditionOperator.And" and "EConditionOperator.Or"
- [Request] Add MinMax support for float2
- Inside serialized item list, show if and enable if not works HOT 1
- [Question] How to change how ShowNonSerializedFields are rendered HOT 1
- Naughty Attributes doesn't cooperate with a custom editor script, can it be fixed? HOT 1
- My favorite Attributes , Will it be updated? HOT 1
- Feature request - order for box groups HOT 3
- ScriptableObject not saving SubclassSelector HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from naughtyattributes.