Skip to content

Commit 0690d07

Browse files
author
Unity Technologies
committed
Unity 2022.1.0b15 C# reference source code
1 parent 853a8a3 commit 0690d07

File tree

17 files changed

+109
-90
lines changed

17 files changed

+109
-90
lines changed

Editor/Mono/BuildPlayerWindowBuildMethods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static void BuildPlayer(BuildPlayerOptions options)
170170
bool locationPathExistedBeforeBuild = System.IO.Directory.Exists(options.locationPathName);
171171
// Trigger build.
172172
// Note: report will be null, if delayToAfterScriptReload = true
173-
var report = BuildPipeline.BuildPlayerInternalNoCheck(options.scenes, options.locationPathName, PostprocessBuildPlayer.GetStreamingAssetsBundleManifestPath(), options.targetGroup, options.target, options.subtarget, options.options, options.extraScriptingDefines, delayToAfterScriptReload);
173+
var report = BuildPipeline.BuildPlayerInternalNoCheck(options.scenes, options.locationPathName, options.assetBundleManifestPath, options.targetGroup, options.target, options.subtarget, options.options, options.extraScriptingDefines, delayToAfterScriptReload);
174174

175175
if (report != null
176176
)
@@ -308,7 +308,7 @@ internal static BuildPlayerOptions GetBuildPlayerOptionsInternal(bool askForBuil
308308
options.subtarget = subtarget;
309309
options.targetGroup = buildTargetGroup;
310310
options.locationPathName = EditorUserBuildSettings.GetBuildLocation(buildTarget);
311-
options.assetBundleManifestPath = null;
311+
options.assetBundleManifestPath = PostprocessBuildPlayer.GetStreamingAssetsBundleManifestPath();
312312

313313
// Build a list of scenes that are enabled
314314
ArrayList scenesList = new ArrayList();

Editor/Mono/GUI/Splitter.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ public void NormalizeRelativeSizes()
178178

179179
public void RealToRelativeSizes()
180180
{
181+
if (relativeSizes.Length == 0)
182+
return;
183+
181184
float check = 1.0f; // try to avoid rounding issues
182185
float total = 0;
183186
int k;
@@ -186,13 +189,23 @@ public void RealToRelativeSizes()
186189
for (k = 0; k < realSizes.Length; k++)
187190
total += realSizes[k];
188191

189-
for (k = 0; k < realSizes.Length; k++)
192+
if (total > 0.001f)
190193
{
191-
relativeSizes[k] = realSizes[k] / total;
192-
check -= relativeSizes[k];
193-
}
194-
if (relativeSizes.Length > 0)
194+
for (k = 0; k < realSizes.Length; k++)
195+
{
196+
relativeSizes[k] = realSizes[k] / total;
197+
check -= relativeSizes[k];
198+
}
199+
195200
relativeSizes[relativeSizes.Length - 1] += check;
201+
}
202+
else
203+
{
204+
// Distribute evenly
205+
float relativeSize = 1f / relativeSizes.Length;
206+
for (k = 0; k < relativeSizes.Length; k++)
207+
relativeSizes[k] = relativeSize;
208+
}
196209
}
197210

198211
public void RelativeToRealSizes(float totalSpace)

Editor/Mono/Graphics/ShaderCompilerData.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public struct ShaderCompilerData
4545
private ShaderRequirements m_ShaderRequirements;
4646
private GraphicsTier m_GraphicsTier;
4747
private ShaderCompilerPlatform m_ShaderCompilerPlatform;
48+
private BuildTarget m_BuildTarget;
4849

4950
public ShaderRequirements shaderRequirements
5051
{
@@ -60,6 +61,8 @@ public ShaderCompilerPlatform shaderCompilerPlatform
6061
{
6162
get { return m_ShaderCompilerPlatform; }
6263
}
64+
65+
public BuildTarget buildTarget { get { return m_BuildTarget; } }
6366
}
6467

6568
public enum ShaderCompilerPlatform

Editor/Mono/Inspector/AvatarMaskInspector.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,16 +750,19 @@ protected override void ToggleAll()
750750

751751
static bool GetFirstActiveValue(SerializedNodeInfo parent, out bool value)
752752
{
753-
foreach (var treeViewItem in parent.children)
753+
if (parent.children != null)
754754
{
755-
var child = (SerializedNodeInfo)treeViewItem;
756-
if (child.m_State != SerializedNodeInfo.State.Disabled)
755+
foreach (var treeViewItem in parent.children)
757756
{
758-
value = child.nodeState;
759-
return true;
757+
var child = (SerializedNodeInfo)treeViewItem;
758+
if (child.m_State != SerializedNodeInfo.State.Disabled)
759+
{
760+
value = child.nodeState;
761+
return true;
762+
}
763+
if (GetFirstActiveValue(child, out value))
764+
return true;
760765
}
761-
if (GetFirstActiveValue(child, out value))
762-
return true;
763766
}
764767
value = false;
765768
return false;

Editor/Mono/Inspector/CubemapPreview.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private void RenderCubemap(Texture t, Vector2 previewDir, float previewDistance,
192192
}
193193

194194
m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, m_Material, 0);
195-
m_PreviewUtility.Render();
195+
m_PreviewUtility.Render(Unsupported.useScriptableRenderPipeline);
196196
}
197197
}
198198
}

Editor/Mono/Inspector/MaterialEditor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,15 +3032,17 @@ internal static void AddAdditionalMaterialMenuItems(GenericMenu menu)
30323032
materialForContextMenu = null;
30333033

30343034
menu.AddItem(new GUIContent("Create Variant for Renderer"), false, () => {
3035-
var variant = new Material(material) { name = material.name + " Variant", parent = material };
30363035

30373036
var directory = "Assets/Materials";
30383037
var assetPath = AssetDatabase.GetAssetPath(material);
3038+
var assetName = Path.GetFileNameWithoutExtension(assetPath) + " Variant";
30393039
var package = PackageManager.PackageInfo.FindForAssetPath(assetPath);
30403040
if (package == null || package.source == PackageManager.PackageSource.Local)
30413041
directory = Path.GetDirectoryName(assetPath);
3042+
3043+
var path = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(directory, assetName + ".mat"));
3044+
var variant = new Material(material) { name = assetName, parent = material };
30423045
Directory.CreateDirectory(directory);
3043-
var path = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(directory, variant.name + ".mat"));
30443046
AssetDatabase.CreateAsset(variant, path);
30453047

30463048
foreach (var renderer in renderers)

External/TinyProfiler/TraceMaker.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ public static void EmitRawTraceEvents(List<TinyProfiler.ThreadContext> threadCon
5252
if (!externalFile.FileExists())
5353
continue;
5454

55-
using (var stream = File.OpenRead(externalFile.ToString(SlashMode.Native)))
55+
// Important: need to read this file as text mode, to avoid copying byte-order-marks.
56+
using (var stream = File.OpenText(externalFile.ToString(SlashMode.Native)))
5657
{
57-
stream.CopyTo(textWriter.BaseStream);
58+
while (!stream.EndOfStream)
59+
textWriter.WriteLine(stream.ReadLine());
5860
}
5961
}
6062
}

ModuleOverrides/com.unity.ui/Core/Controls/BaseBoolField.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ public string text
9898
/// </remarks>
9999
protected virtual void InitLabel()
100100
{
101-
m_Label = new Label
102-
{
103-
pickingMode = PickingMode.Ignore
104-
};
101+
m_Label = new Label();
105102
visualInput.Add(m_Label);
106103
}
107104

ModuleOverrides/com.unity.ui/Core/Controls/BaseTreeView.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,11 @@ public bool TryRemoveItem(int id)
328328
internal override void OnViewDataReady()
329329
{
330330
base.OnViewDataReady();
331-
viewController.RebuildTree();
332-
RefreshItems();
331+
if (viewController != null)
332+
{
333+
viewController.RebuildTree();
334+
RefreshItems();
335+
}
333336
}
334337

335338
private void OnScrollViewKeyDown(KeyDownEvent evt)

ModuleOverrides/com.unity.ui/Core/Controls/InputField/BaseField.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,12 @@ protected override void ExecuteDefaultAction(EventBase evt)
463463
{
464464
TooltipEvent e = (TooltipEvent)evt;
465465

466+
//When a label is present, set the tooltip position centered on the label, otherwise center it on the entire field.
466467
e.rect = !string.IsNullOrEmpty(label) ? labelElement.worldBound : worldBound;
467468

468-
e.tooltip = tooltip;
469+
if(!string.IsNullOrEmpty(tooltip))
470+
e.tooltip = tooltip;
471+
469472
e.StopImmediatePropagation();
470473
}
471474
}

0 commit comments

Comments
 (0)