diff --git a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs index ad974c55a..924f5aeb3 100644 --- a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs @@ -24,43 +24,6 @@ namespace FlaxEditor.CustomEditors.Dedicated { private Guid _linkedPrefabId; - /// - 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); - } - /// protected override List GetItemsForType(ScriptType type) { diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs index 485a9b735..9e7295e7e 100644 --- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs +++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs @@ -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) { diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 900d802ed..30ca06daf 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -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; diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index 334021c28..88da10f0e 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -79,7 +79,7 @@ public: /// /// Gets the object layer (index). Can be used for selective rendering or ignoring raycasts. /// - 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: /// /// Gets the name of the tag. /// - 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; /// @@ -355,7 +355,7 @@ public: /// /// Gets the actor static fags. /// - 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: /// /// Resets the actor local transform. /// - FORCE_INLINE void ResetLocalTransform() - { - SetLocalTransform(Transform::Identity); - } + void ResetLocalTransform(); /// /// Gets local transform of the actor in parent actor space. @@ -523,7 +520,7 @@ public: /// /// Gets local position of the actor in parent actor space. /// - 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: /// /// Gets local rotation of the actor in parent actor space. /// - 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: /// /// Gets local scale vector of the actor in parent actor space. /// - 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: /// The script or null. Script* GetScriptByPrefabObjectId(const Guid& prefabObjectId) const; -public: - /// /// Gets a value indicating whether this actor is a prefab instance root object. /// - API_PROPERTY() FORCE_INLINE bool IsPrefabRoot() const - { - return _isPrefabRoot != 0; - } + API_PROPERTY() bool IsPrefabRoot() const; public: diff --git a/Source/Engine/Navigation/NavMesh.h b/Source/Engine/Navigation/NavMesh.h index f1a901967..c9096d323 100644 --- a/Source/Engine/Navigation/NavMesh.h +++ b/Source/Engine/Navigation/NavMesh.h @@ -39,14 +39,14 @@ public: /// /// If checked, the navmesh will be drawn in debug view when showing navigation data. /// - API_FIELD(Attributes="EditorOrder(-10), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true; + API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true; #endif /// /// The navigation mesh properties. /// - API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties; + API_FIELD(Attributes="EditorOrder(10), EditorDisplay(\"Nav Mesh\")") NavMeshProperties Properties; public: