Inherit from Melee weapon and t he inspector is drawing wrong

Hello,
So, I tried creating a new component by inheriting from Melee weapon as I need to override a couple of the methods.
When I add the component to my weapon (because my custom script doesn't show up in the item builder, I'm assuming its in a wrong folder or something), the inspector doesn't draw the Animator Audio section correctly.
Instead of this:
1627440426999.png

My custom component is drawing this:
1627440465581.png
I haven't done anything to the inspector code, because I don't need to change or touch any of the fields, just how a couple methods work, so I don't understand why it is doing this.
 
The ShootableWeapon component uses a custom inspector, ShootableWeaponInspector. You can simply copy this script and rename it to match your own script (and make sure to put it within an Editor folder), then just change the CustomEditor line at the top - [CustomEditor(typeof(ShootableWeapon))] - and change ShootableWeapon to match your class.
 
Why ShootableWeaponInspector? Its inheriting from MeleeWeapon. I don't need to draw anything differently, or additional. The Use Animator Audio State Set is being drawn incorrectly and that's handled by UsableItemInspector (not even the shootable or melee weapon inspector scripts). So I really don't understand what is happening. (Also, I looked further down the inspector and it is also drawing the recoil animator audio state selector incorrectly).
I've even created my own custom editor script just for my ComboMeleeWeapon and inherited it from UsableItemInspector while copying the entirety of MeleeWeaponInspector over. It still draws wrong.
 
I don't know how it was causing the problem, but it appears I was getting the bug because I did not remove the original MeleeWeapon component with the same ID as my custom one.
 
Yeah I meant MeleeWeaponInspector not ShootableWeaponInspector, my bad. MeleeWeaponInspector is a subclass of UsableItemInspector so it will include that animator audio states inspector drawing. So if you've got a subclass of MeleeWeapon which for some reason is not finding the right custom inspector, then Unity will just draw the default inspector rather than the way it's designed to look/work with the custom inspector.

Glad you worked something out though!
 
Top