Daniele Bartolini пре 2 година
родитељ
комит
0f6e3f0873
2 измењених фајлова са 12 додато и 2 уклоњено
  1. 1 0
      docs/changelog.rst
  2. 11 2
      samples/core/editors/unit_preview/unit_preview.lua

+ 1 - 0
docs/changelog.rst

@@ -12,6 +12,7 @@ Changelog
 
 * Added an option to use the debug keystore when deploying APKs for Android.
 * Added the ability to copy the path of files in the Project Browser.
+* Fixed unit preview in the Resource Chooser.
 
 0.49.0 --- 27 Nov 2023
 ----------------------

+ 11 - 2
samples/core/editors/unit_preview/unit_preview.lua

@@ -23,8 +23,17 @@ function UnitPreview:update(dt)
 	if self._object then
 		local obb_tm, obb_he = self._object:obb()
 
-		local camera_pos = Vector3(1, 1, 1)
-		local camera_rot = Quaternion.look(Vector3.normalize(-camera_pos))
+		local camera_pos
+		local camera_rot
+
+		if RenderWorld.sprite_instance(self._rw, self._object._unit_id) then
+			camera_pos = Vector3(0, 1, 0)
+			camera_rot = Quaternion.look(Vector3.normalize(-camera_pos), Vector3(0, 0, 1))
+		else
+			camera_pos = Vector3(1, 1, -1)
+			camera_rot = Quaternion.look(Vector3.normalize(-camera_pos))
+		end
+
 		local camera_pose = Matrix4x4.from_quaternion_translation(camera_rot, camera_pos)
 
 		self._camera:set_local_pose(camera_pose)