Tilt Five™ Unity API  1.4.1
ScaleSettings.cs
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020-2023 Tilt Five, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 using UnityEngine;
18 
19 namespace TiltFive
20 {
21 
25  [System.Serializable]
26  public class ScaleSettings
27  {
31  public LengthUnit contentScaleUnit = LengthUnit.Centimeters;
32 
50  public float contentScaleRatio = 5f;
51 
66 
67  public float worldSpaceUnitsPerPhysicalMeter => 1 / Mathf.Max(physicalMetersPerWorldSpaceUnit, float.Epsilon); // No dividing by zero.
68 
69  public float oneUnitLengthInMeters => (new Length(1, contentScaleUnit)).ToMeters;
70 
78  public bool legacyInvertGameboardScale = false;
79 
80  public const float MIN_CONTENT_SCALE_RATIO = 0.0000001f;
81 
82  public float GetScaleToUWRLD_UGBD(float gameboardScale)
83  {
84  float scaleToUWRLD_UGBD = 0.0f;
85 
87  float scaleToUGBD_UWRLD = physicalMetersPerWorldSpaceUnit * gameboardScale;
88  scaleToUWRLD_UGBD = scaleToUGBD_UWRLD > 0
89  ? 1f / scaleToUGBD_UWRLD
90  : 1f / float.Epsilon;
91  } else {
92  scaleToUWRLD_UGBD = gameboardScale / physicalMetersPerWorldSpaceUnit;
93  }
94 
95  return scaleToUWRLD_UGBD;
96  }
97 
98 #if UNITY_EDITOR
99  public bool copyPlayerOneScaleRatio = true;
100  public bool copyPlayerOneScaleUnit = true;
101 #endif
102 
103  internal ScaleSettings Copy()
104  {
105  return (ScaleSettings)MemberwiseClone();
106  }
107  }
108 }
ScaleSettings contains the scale data used to translate between Unity units and the user's physical s...
bool legacyInvertGameboardScale
Whether to enable the old, incorrect, behavior whereby the inverse of the gameboard GameObject's scal...
float physicalMetersPerWorldSpaceUnit
The content scale, in terms of meters per world space unit.
const float MIN_CONTENT_SCALE_RATIO
float worldSpaceUnitsPerPhysicalMeter
LengthUnit contentScaleUnit
The real-world unit to be compared against when using .
float contentScaleRatio
The scaling ratio relates physical distances to world-space units.
float GetScaleToUWRLD_UGBD(float gameboardScale)
Definition: Log.cs:21
LengthUnit
Definition: Length.cs:22
float ToMeters
The Length, converted to meters.
Definition: Length.cs:94