Tilt Five™ Unity API  1.3.0
 
Loading...
Searching...
No Matches
ScaleSettings.cs
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020-2022 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
17using UnityEngine;
18
19namespace TiltFive
20{
21
25 [System.Serializable]
26 public class ScaleSettings
27 {
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
71 public const float MIN_CONTENT_SCALE_RATIO = 0.0000001f;
72
73 public float GetScaleToUWRLD_UGBD(float gameboardScale)
74 {
75 float scaleToUGBD_UWRLD = physicalMetersPerWorldSpaceUnit * gameboardScale;
76 float scaleToUWRLD_UGBD = scaleToUGBD_UWRLD > 0
77 ? 1f / scaleToUGBD_UWRLD
78 : 1f / float.Epsilon;
79
80 return scaleToUWRLD_UGBD;
81 }
82
83#if UNITY_EDITOR
84 public bool copyPlayerOneScaleRatio = true;
85 public bool copyPlayerOneScaleUnit = true;
86#endif
87
88 internal ScaleSettings Copy()
89 {
90 return (ScaleSettings)MemberwiseClone();
91 }
92 }
93}
ScaleSettings contains the scale data used to translate between Unity units and the user's physical s...
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