[ad_1]
I’m making a customized UI with the UI Builder for my scriptable object that holds some information for the AI Participant. All of it labored fantastic till I added a 3rd slider for a brand new worth I wanted; now the item will not preview within the inspector and I get an InvalidCastException for no purpose. The sliders are for floats, and the values within the scriptable object are additionally floats, and the customized objects I’m utilizing for an inventory was working too, and I did not change it in any respect. I attempted debugging it by eradicating all information bindings within the builder in order that it simply renders the UI with none information, however it nonetheless offers the identical error despite the fact that no information is being binded…
[CustomEditor(typeof(AiBrainData))]
public class AiControllerDataEditor : Editor
{
non-public const string path = "UI/AI/ai_brain_data";
public override VisualElement CreateInspectorGUI()
{
VisualTreeAsset vta = (VisualTreeAsset)Assets.Load(path);
VisualElement root = new();
vta.CloneTree(root);
return root;
}
}
[CreateAssetMenu(menuName = "AI/Brain")]
public class AiBrainData : ScriptableObject
{
[SerializeField] non-public BrainFeature[] _features;
public BrainFeature[] BrainFeatures => _features;
[SerializeField, Range(1f, 0f)] non-public float _reductionFactor = 0.5f;
public float ReductionFactor => 1f - _reductionFactor;
[SerializeField, Range(0f, 10f)] non-public float _increasionAmount = 0.5f;
public float IncreasionAmount => _increasionAmount;
[SerializeField, Range(0f, 5f)] non-public float _normalizationStep = 2.5f;
public float NormalizationStep => _normalizationStep;
}
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<Model src="undertaking://database/Property/Assets/UI/AI/ai_brain_data.uss?fileID=7433441132597879392&guid=65086b2200eb7e14eb6c4612fdf51cb5&sort=3#ai_brain_data" />
<ui:VisualElement identify="root">
<ui:Label textual content="Mind Options" identify="title" fashion="margin-left: 4px; margin-right: 4px; margin-top: 4px; margin-bottom: 4px; -unity-font-style: regular; font-size: 14px; -unity-text-align: upper-center;" />
<ui:ListView focusable="false" identify="gadgets" picking-mode="Ignore" header-title="Mind Options" show-bound-collection-size="false" virtualization-method="DynamicHeight" binding-path="_features" view-data-key="_features" fashion="margin-bottom: 4px; background-color: rgb(202, 202, 202); border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(176, 176, 176); border-right-color: rgb(176, 176, 176); border-top-color: rgb(176, 176, 176); border-bottom-color: rgb(176, 176, 176); padding-top: 4px; padding-right: 8px; padding-left: 2px; padding-bottom: 2px;" />
<ui:Slider picking-mode="Ignore" label="Discount" worth="0.5" high-value="0" identify="discount" show-input-field="true" tooltip="The discount issue for a characteristic final result." low-value="1" binding-path="_reductionFactor" class="slider_brain" />
<ui:Slider picking-mode="Ignore" label="Increasion" worth="5" high-value="10" identify="increasion" show-input-field="true" focusable="true" binding-path="_increasionAmount" class="slider_brain" />
<ui:Slider picking-mode="Ignore" label="Regular Step" worth="2.5" high-value="5" identify="regular" tooltip="The step at which a decreased characteristic is normalized to it's weight." show-input-field="true" focusable="true" binding-path="_normalizationStep" class="slider_brain" />
</ui:VisualElement>
</ui:UXML>
EDIT: The error simply factors to the CreateInspectorGUI technique in AiControllerDataEditor class
[ad_2]