Skip to content

Commit

Permalink
Adds check for frame type with no frame game objects set
Browse files Browse the repository at this point in the history
  • Loading branch information
codec-xyz committed Dec 15, 2023
1 parent 80434a1 commit 7fac11d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Editor/PhotoFrameEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public override void OnInspectorGUI() {

GUILayout.Label($"{photoFrame.photoSourceSize.x}px x {photoFrame.photoSourceSize.y}px - {photoFrame.photo.name}");
GUILayout.Label($"{finalRes.x}px x {finalRes.y}px final resolution - " + (dataSave * 100f).ToString("0.00") + "% of original - " + (cutoutPercent * 100f).ToString("0.00") + "% cutout");
if(photoFrame.frameType != null && photoFrame.frameType.photoFrames.Length != 0) {
if(photoFrame.frameType != null && photoFrame.frameType.photoFrames != null && photoFrame.frameType.photoFrames.Length != 0) {
string frameInfo = new Fraction(frameAspectRatio).ToString().Replace("/", " \u2215 ") + " = " + frameAspectRatio.ToString("0.000");
GUILayout.Label($"Frame - {frameInfo}");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Special/PhotoFrameType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PhotoFrameType : ScriptableObject {
public GameObject[] photoFrames;
public Vector2[] aspectRatios;

public bool haveFrames() => photoFrames?.Length > 0 && aspectRatios?.Length > 0;
public bool haveFrames() => photoFrames?.Length > 0 && aspectRatios?.Length > 0 && photoFrames.Where(a => a != null).Any();
public GameObject getFrame(int index) => photoFrames?.ElementAtOrDefault(index);

public GameObject getOrGenerateFrame(int index, float aspectRatio, out bool isGenerated, Vector2 size, bool doGeneration = true) {
Expand Down Expand Up @@ -121,7 +121,7 @@ public float getRatio(int index) {

public int? findFrame(float aspectRatio, bool needsExactMatch, out float frameAspectRatio) {
frameAspectRatio = aspectRatio;
if(aspectRatios == null || aspectRatios.Length == 0) return null;
if(aspectRatios == null || aspectRatios.Length == 0 || !haveFrames()) return null;

var frames = aspectRatios.Select((ratioVec, i) => {
float ratio = Utils.ConvertRatio(ratioVec, 0);
Expand Down

0 comments on commit 7fac11d

Please sign in to comment.