Fix not using hardcoded order for showing Actor main properties in editor
This commit is contained in:
@@ -24,43 +24,6 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
{
|
||||
private Guid _linkedPrefabId;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void SpawnProperty(LayoutElementsContainer itemLayout, ValueContainer itemValues, ItemInfo item)
|
||||
{
|
||||
// Note: we cannot specify actor properties editor types directly because we want to keep editor classes in FlaxEditor assembly
|
||||
int order = item.Order?.Order ?? int.MinValue;
|
||||
switch (order)
|
||||
{
|
||||
// Override static flags editor
|
||||
case -80:
|
||||
item.CustomEditor = new CustomEditorAttribute(typeof(ActorStaticFlagsEditor));
|
||||
break;
|
||||
|
||||
// Override layer editor
|
||||
case -69:
|
||||
item.CustomEditor = new CustomEditorAttribute(typeof(ActorLayerEditor));
|
||||
break;
|
||||
|
||||
// Override tag editor
|
||||
case -68:
|
||||
item.CustomEditor = new CustomEditorAttribute(typeof(ActorTagEditor));
|
||||
break;
|
||||
|
||||
// Override position/scale editor
|
||||
case -30:
|
||||
case -10:
|
||||
item.CustomEditor = new CustomEditorAttribute(typeof(ActorTransformEditor.PositionScaleEditor));
|
||||
break;
|
||||
|
||||
// Override orientation editor
|
||||
case -20:
|
||||
item.CustomEditor = new CustomEditorAttribute(typeof(ActorTransformEditor.OrientationEditor));
|
||||
break;
|
||||
}
|
||||
|
||||
base.SpawnProperty(itemLayout, itemValues, item);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override List<ItemInfo> GetItemsForType(ScriptType type)
|
||||
{
|
||||
|
||||
@@ -517,23 +517,22 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
if (item.Header != null)
|
||||
itemLayout.Header(item.Header.Text);
|
||||
|
||||
// Peek values
|
||||
ValueContainer itemValues;
|
||||
try
|
||||
{
|
||||
itemValues = item.GetValues(Values);
|
||||
// Peek values
|
||||
ValueContainer itemValues = item.GetValues(Values);
|
||||
|
||||
// Spawn property editor
|
||||
SpawnProperty(itemLayout, itemValues, item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Editor.LogWarning("Failed to get object values for item " + item);
|
||||
Editor.LogWarning("Failed to setup values and UI for item " + item);
|
||||
Editor.LogWarning(ex.Message);
|
||||
Editor.LogWarning(ex.StackTrace);
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn property editor
|
||||
SpawnProperty(itemLayout, itemValues, item);
|
||||
|
||||
// Expand all parent groups if need to
|
||||
if (item.ExpandGroups)
|
||||
{
|
||||
|
||||
@@ -597,6 +597,11 @@ void Actor::SetDirection(const Vector3& value)
|
||||
SetOrientation(orientation);
|
||||
}
|
||||
|
||||
void Actor::ResetLocalTransform()
|
||||
{
|
||||
SetLocalTransform(Transform::Identity);
|
||||
}
|
||||
|
||||
void Actor::SetLocalTransform(const Transform& value)
|
||||
{
|
||||
CHECK(!value.IsNanOrInfinity());
|
||||
@@ -1258,6 +1263,11 @@ Script* Actor::GetScriptByPrefabObjectId(const Guid& prefabObjectId) const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Actor::IsPrefabRoot() const
|
||||
{
|
||||
return _isPrefabRoot != 0;
|
||||
}
|
||||
|
||||
Actor* Actor::FindActor(const StringView& name) const
|
||||
{
|
||||
Actor* result = nullptr;
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the object layer (index). Can be used for selective rendering or ignoring raycasts.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-69)")
|
||||
API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-69), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorLayerEditor\")")
|
||||
FORCE_INLINE int32 GetLayer() const
|
||||
{
|
||||
return _layer;
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the name of the tag.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-68)")
|
||||
API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-68), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorTagEditor\")")
|
||||
const String& GetTag() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -355,7 +355,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the actor static fags.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-80)")
|
||||
API_PROPERTY(Attributes="NoAnimate, EditorDisplay(\"General\"), EditorOrder(-80), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorStaticFlagsEditor\")")
|
||||
FORCE_INLINE StaticFlags GetStaticFlags() const
|
||||
{
|
||||
return _staticFlags;
|
||||
@@ -500,10 +500,7 @@ public:
|
||||
/// <summary>
|
||||
/// Resets the actor local transform.
|
||||
/// </summary>
|
||||
FORCE_INLINE void ResetLocalTransform()
|
||||
{
|
||||
SetLocalTransform(Transform::Identity);
|
||||
}
|
||||
void ResetLocalTransform();
|
||||
|
||||
/// <summary>
|
||||
/// Gets local transform of the actor in parent actor space.
|
||||
@@ -523,7 +520,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets local position of the actor in parent actor space.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorDisplay(\"Transform\", \"Position\"), DefaultValue(typeof(Vector3), \"0,0,0\"), EditorOrder(-30), NoSerialize")
|
||||
API_PROPERTY(Attributes="EditorDisplay(\"Transform\", \"Position\"), DefaultValue(typeof(Vector3), \"0,0,0\"), EditorOrder(-30), NoSerialize, CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorTransformEditor+PositionScaleEditor\")")
|
||||
FORCE_INLINE Vector3 GetLocalPosition() const
|
||||
{
|
||||
return _localTransform.Translation;
|
||||
@@ -538,7 +535,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets local rotation of the actor in parent actor space.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorDisplay(\"Transform\", \"Rotation\"), DefaultValue(typeof(Quaternion), \"0,0,0,1\"), EditorOrder(-20), NoSerialize")
|
||||
API_PROPERTY(Attributes="EditorDisplay(\"Transform\", \"Rotation\"), DefaultValue(typeof(Quaternion), \"0,0,0,1\"), EditorOrder(-20), NoSerialize, CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorTransformEditor+OrientationEditor\")")
|
||||
FORCE_INLINE Quaternion GetLocalOrientation() const
|
||||
{
|
||||
return _localTransform.Orientation;
|
||||
@@ -553,7 +550,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets local scale vector of the actor in parent actor space.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorDisplay(\"Transform\", \"Scale\"), DefaultValue(typeof(Vector3), \"1,1,1\"), Limit(float.MinValue, float.MaxValue, 0.01f), EditorOrder(-10), NoSerialize")
|
||||
API_PROPERTY(Attributes="EditorDisplay(\"Transform\", \"Scale\"), DefaultValue(typeof(Vector3), \"1,1,1\"), Limit(float.MinValue, float.MaxValue, 0.01f), EditorOrder(-10), NoSerialize, CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.ActorTransformEditor+PositionScaleEditor\")")
|
||||
FORCE_INLINE Vector3 GetLocalScale() const
|
||||
{
|
||||
return _localTransform.Scale;
|
||||
@@ -708,15 +705,10 @@ public:
|
||||
/// <returns>The script or null.</returns>
|
||||
Script* GetScriptByPrefabObjectId(const Guid& prefabObjectId) const;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this actor is a prefab instance root object.
|
||||
/// </summary>
|
||||
API_PROPERTY() FORCE_INLINE bool IsPrefabRoot() const
|
||||
{
|
||||
return _isPrefabRoot != 0;
|
||||
}
|
||||
API_PROPERTY() bool IsPrefabRoot() const;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ public:
|
||||
/// <summary>
|
||||
/// If checked, the navmesh will be drawn in debug view when showing navigation data.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(-10), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true;
|
||||
API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true;
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The navigation mesh properties.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties;
|
||||
API_FIELD(Attributes="EditorOrder(10), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user