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;
|
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 />
|
/// <inheritdoc />
|
||||||
protected override List<ItemInfo> GetItemsForType(ScriptType type)
|
protected override List<ItemInfo> GetItemsForType(ScriptType type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -517,23 +517,22 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
if (item.Header != null)
|
if (item.Header != null)
|
||||||
itemLayout.Header(item.Header.Text);
|
itemLayout.Header(item.Header.Text);
|
||||||
|
|
||||||
// Peek values
|
|
||||||
ValueContainer itemValues;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
itemValues = item.GetValues(Values);
|
// Peek values
|
||||||
|
ValueContainer itemValues = item.GetValues(Values);
|
||||||
|
|
||||||
|
// Spawn property editor
|
||||||
|
SpawnProperty(itemLayout, itemValues, item);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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.Message);
|
||||||
Editor.LogWarning(ex.StackTrace);
|
Editor.LogWarning(ex.StackTrace);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn property editor
|
|
||||||
SpawnProperty(itemLayout, itemValues, item);
|
|
||||||
|
|
||||||
// Expand all parent groups if need to
|
// Expand all parent groups if need to
|
||||||
if (item.ExpandGroups)
|
if (item.ExpandGroups)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -597,6 +597,11 @@ void Actor::SetDirection(const Vector3& value)
|
|||||||
SetOrientation(orientation);
|
SetOrientation(orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Actor::ResetLocalTransform()
|
||||||
|
{
|
||||||
|
SetLocalTransform(Transform::Identity);
|
||||||
|
}
|
||||||
|
|
||||||
void Actor::SetLocalTransform(const Transform& value)
|
void Actor::SetLocalTransform(const Transform& value)
|
||||||
{
|
{
|
||||||
CHECK(!value.IsNanOrInfinity());
|
CHECK(!value.IsNanOrInfinity());
|
||||||
@@ -1258,6 +1263,11 @@ Script* Actor::GetScriptByPrefabObjectId(const Guid& prefabObjectId) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Actor::IsPrefabRoot() const
|
||||||
|
{
|
||||||
|
return _isPrefabRoot != 0;
|
||||||
|
}
|
||||||
|
|
||||||
Actor* Actor::FindActor(const StringView& name) const
|
Actor* Actor::FindActor(const StringView& name) const
|
||||||
{
|
{
|
||||||
Actor* result = nullptr;
|
Actor* result = nullptr;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the object layer (index). Can be used for selective rendering or ignoring raycasts.
|
/// Gets the object layer (index). Can be used for selective rendering or ignoring raycasts.
|
||||||
/// </summary>
|
/// </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
|
FORCE_INLINE int32 GetLayer() const
|
||||||
{
|
{
|
||||||
return _layer;
|
return _layer;
|
||||||
@@ -123,7 +123,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the tag.
|
/// Gets the name of the tag.
|
||||||
/// </summary>
|
/// </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;
|
const String& GetTag() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -355,7 +355,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the actor static fags.
|
/// Gets the actor static fags.
|
||||||
/// </summary>
|
/// </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
|
FORCE_INLINE StaticFlags GetStaticFlags() const
|
||||||
{
|
{
|
||||||
return _staticFlags;
|
return _staticFlags;
|
||||||
@@ -500,10 +500,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets the actor local transform.
|
/// Resets the actor local transform.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FORCE_INLINE void ResetLocalTransform()
|
void ResetLocalTransform();
|
||||||
{
|
|
||||||
SetLocalTransform(Transform::Identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets local transform of the actor in parent actor space.
|
/// Gets local transform of the actor in parent actor space.
|
||||||
@@ -523,7 +520,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets local position of the actor in parent actor space.
|
/// Gets local position of the actor in parent actor space.
|
||||||
/// </summary>
|
/// </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
|
FORCE_INLINE Vector3 GetLocalPosition() const
|
||||||
{
|
{
|
||||||
return _localTransform.Translation;
|
return _localTransform.Translation;
|
||||||
@@ -538,7 +535,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets local rotation of the actor in parent actor space.
|
/// Gets local rotation of the actor in parent actor space.
|
||||||
/// </summary>
|
/// </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
|
FORCE_INLINE Quaternion GetLocalOrientation() const
|
||||||
{
|
{
|
||||||
return _localTransform.Orientation;
|
return _localTransform.Orientation;
|
||||||
@@ -553,7 +550,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets local scale vector of the actor in parent actor space.
|
/// Gets local scale vector of the actor in parent actor space.
|
||||||
/// </summary>
|
/// </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
|
FORCE_INLINE Vector3 GetLocalScale() const
|
||||||
{
|
{
|
||||||
return _localTransform.Scale;
|
return _localTransform.Scale;
|
||||||
@@ -708,15 +705,10 @@ public:
|
|||||||
/// <returns>The script or null.</returns>
|
/// <returns>The script or null.</returns>
|
||||||
Script* GetScriptByPrefabObjectId(const Guid& prefabObjectId) const;
|
Script* GetScriptByPrefabObjectId(const Guid& prefabObjectId) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this actor is a prefab instance root object.
|
/// Gets a value indicating whether this actor is a prefab instance root object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_PROPERTY() FORCE_INLINE bool IsPrefabRoot() const
|
API_PROPERTY() bool IsPrefabRoot() const;
|
||||||
{
|
|
||||||
return _isPrefabRoot != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If checked, the navmesh will be drawn in debug view when showing navigation data.
|
/// If checked, the navmesh will be drawn in debug view when showing navigation data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD(Attributes="EditorOrder(-10), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true;
|
API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The navigation mesh properties.
|
/// The navigation mesh properties.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties;
|
API_FIELD(Attributes="EditorOrder(10), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user