Unity SDK Docs 1.5.0-beta.6
Loading...
Searching...
No Matches
ScaleSettings.cs
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
17using UnityEngine;
18using System;
19
20namespace TiltFive
21{
22
26 [System.Serializable]
27 public class ScaleSettings
28 {
32 public LengthUnit contentScaleUnit = LengthUnit.Centimeters;
33
51 public float contentScaleRatio = 5f;
52
67
68 public float worldSpaceUnitsPerPhysicalMeter => 1 / Mathf.Max(physicalMetersPerWorldSpaceUnit, float.Epsilon); // No dividing by zero.
69
70 public float oneUnitLengthInMeters => (new Length(1, contentScaleUnit)).ToMeters;
71
79 public bool legacyInvertGameboardScale = false;
80
81 public const float MIN_CONTENT_SCALE_RATIO = 0.0000001f;
82
83 [Obsolete("ScaleSettings.GetScaleToUWRLD_UGBD is deprecated. Please use ScaleSettings.GetScaleToWorldSpaceFromGameboardSpace instead.")]
84 public float GetScaleToUWRLD_UGBD(float gameboardScale) { return GetScaleToWorldSpaceFromGameboardSpace(gameboardScale); }
85
86 public float GetScaleToWorldSpaceFromGameboardSpace(float gameboardScale)
87 {
88 float scaleToUWRLD_USTAGE = 0.0f;
89
91 float scaleToUSTAGE_UWRLD = physicalMetersPerWorldSpaceUnit * gameboardScale;
92 scaleToUWRLD_USTAGE = scaleToUSTAGE_UWRLD > 0
93 ? 1f / scaleToUSTAGE_UWRLD
94 : 1f / float.Epsilon;
95 } else {
96 scaleToUWRLD_USTAGE = gameboardScale / physicalMetersPerWorldSpaceUnit;
97 }
98
99 return scaleToUWRLD_USTAGE;
100 }
101
102#if UNITY_EDITOR
103 public bool copyPlayerOneScaleRatio = true;
104 public bool copyPlayerOneScaleUnit = true;
105#endif
106
107 internal ScaleSettings Copy()
108 {
109 return (ScaleSettings)MemberwiseClone();
110 }
111 }
112}
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.
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 ToMeters
The Length, converted to meters.
Definition Length.cs:94