Skip to content

Commit

Permalink
Fix issue where images too large fail to load without an informative …
Browse files Browse the repository at this point in the history
…message (#722)

Fixes #688
  • Loading branch information
eeropomell authored Jun 13, 2024
1 parent 6c0d56e commit f6bcc9e
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238935604850335744
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
162 changes: 162 additions & 0 deletions Assets/Prefabs/Panels/ReferencePanel/ReferencePanelTabImage.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -207,6 +225,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -262,6 +298,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -317,6 +371,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -372,6 +444,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -427,6 +517,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -482,6 +590,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -537,6 +663,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down Expand Up @@ -592,6 +736,24 @@ MonoBehaviour:
m_HoverScale: 1.2
m_HoverBoxColliderGrow: 0.2
m_AddOverlay: 0
m_LoadHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238555522805800960
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_ErrorHelpText:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
m_TableEntryReference:
m_KeyId: 238556149774557184
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
19 changes: 17 additions & 2 deletions Assets/Scripts/GUI/LoadBackgroundImageButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

using UnityEngine;
using UnityEngine.Localization;

namespace TiltBrush
{

Expand All @@ -24,10 +26,21 @@ public void RefreshDescription()
{
if (ReferenceImage != null)
{
SetDescriptionText(ReferenceImage.FileName);

// null if image doesn't have error
string errorMessage = ReferenceImage.ImageErrorExtraDescription();

if (errorMessage != null)
{
SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName), errorMessage);
}
else
{
SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName));
}

}
}

override protected void OnButtonPressed()
{
if (ReferenceImage == null)
Expand All @@ -52,6 +65,8 @@ override public void ResetState()
{
SetButtonAvailable(available);
}

RefreshDescription();
}

public void Set360ButtonTexture(Texture2D rTexture, float aspect = -1)
Expand Down
19 changes: 18 additions & 1 deletion Assets/Scripts/GUI/LoadReferenceImageButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using UnityEngine.Localization;
using UnityEngine;

namespace TiltBrush
{

Expand All @@ -23,7 +26,19 @@ public void RefreshDescription()
{
if (ReferenceImage != null)
{
SetDescriptionText(ReferenceImage.FileName);

// null if image doesn't have error
string errorMessage = ReferenceImage.ImageErrorExtraDescription();

if (errorMessage != null)
{
SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName), errorMessage);
}
else
{
SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName));
}

}
}

Expand Down Expand Up @@ -68,6 +83,8 @@ override public void ResetState()
{
SetButtonAvailable(available);
}

RefreshDescription();
}
}
} // namespace TiltBrush
Loading

0 comments on commit f6bcc9e

Please sign in to comment.