Skip to content

Commit 507e672

Browse files
author
Unity Technologies
committed
Unity 2018.3.0b4 C# reference source code
1 parent 198807e commit 507e672

File tree

49 files changed

+1772
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1772
-380
lines changed

Editor/Mono/BuildPipeline.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using UnityEngine.Bindings;
1010
using UnityEditor.Build.Reporting;
1111
using Mono.Cecil;
12+
using UnityEditor.Scripting.ScriptCompilation;
1213

1314
namespace UnityEditor
1415
{
@@ -179,6 +180,7 @@ public class BuildPipeline
179180
internal static extern BuildTargetGroup GetBuildTargetGroupByName(string platform);
180181

181182
internal static extern BuildTarget GetBuildTargetByName(string platform);
183+
internal static extern EditorScriptCompilationOptions GetScriptCompileFlags(BuildOptions buildOptions, BuildTarget buildTarget);
182184

183185
[FreeFunction]
184186
internal static extern string GetBuildTargetGroupDisplayName(BuildTargetGroup targetPlatformGroup);

Editor/Mono/Camera/BuiltinBakedReflectionSystem.bindings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ public void Clear()
6464
Internal_Clear();
6565
}
6666

67+
public bool BakeAllReflectionProbes()
68+
{
69+
if (disposed)
70+
throw new ObjectDisposedException("BuiltinBakedReflectionSystem");
71+
72+
return Internal_BakeAllReflectionProbes();
73+
}
74+
6775
public void Cancel()
6876
{
6977
// Cancel is empty on purpose
@@ -120,5 +128,6 @@ void Internal_BuiltinBakedReflectionSystem_SetIsDone(bool isDone)
120128
extern void Internal_SynchronizeReflectionProbes();
121129
extern void Internal_Clear();
122130
extern void Internal_SetPtr(BuiltinBakedReflectionSystem ptr);
131+
extern bool Internal_BakeAllReflectionProbes();
123132
}
124133
}

Editor/Mono/Camera/IScriptableBakedReflectionSystem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ public interface IScriptableBakedReflectionSystem : IDisposable
1616
void SynchronizeReflectionProbes();
1717
void Clear();
1818
void Cancel();
19+
bool BakeAllReflectionProbes();
1920
}
2021
}

Editor/Mono/Camera/ScriptableBakedReflectionSystem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public virtual void Tick(SceneStateHash sceneStateHash, IScriptableBakedReflecti
2121
public virtual void SynchronizeReflectionProbes() {}
2222
public virtual void Clear() {}
2323
public virtual void Cancel() {}
24+
public virtual bool BakeAllReflectionProbes() { return false; }
2425

2526
protected virtual void Dispose(bool disposing) {}
2627

Editor/Mono/Camera/ScriptableBakedReflectionSystemWrapper.bindings.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ void Internal_ScriptableBakedReflectionSystemWrapper_Cancel()
118118
implementation.Cancel();
119119
}
120120

121+
[RequiredByNativeCode]
122+
bool Internal_ScriptableBakedReflectionSystemWrapper_BakeAllReflectionProbes()
123+
{
124+
if (Disposed)
125+
throw new ObjectDisposedException("ScriptableBakedReflectionSystemWrapper");
126+
127+
if (implementation != null)
128+
return implementation.BakeAllReflectionProbes();
129+
130+
return false;
131+
}
132+
121133
[StaticAccessor("ScriptableBakedReflectionSystem", StaticAccessorType.DoubleColon)]
122134
static extern void ScriptingEnterStage(IntPtr objPtr, int stage, string progressMessage, float progress);
123135

Editor/Mono/GI/LightmapVisualization.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ internal sealed partial class LightmapVisualizationUtility
3131
[StaticAccessor("VisualisationManager::Get()", StaticAccessorType.Arrow)]
3232
internal extern static bool IsBakedTextureType(GITextureType textureType);
3333

34+
[StaticAccessor("VisualisationManager::Get()", StaticAccessorType.Arrow)]
35+
internal extern static bool IsAtlasTextureType(GITextureType textureType);
36+
3437
[StaticAccessor("VisualisationManager::Get()", StaticAccessorType.Arrow)]
3538
public extern static VisualisationGITexture[] GetRealtimeGITextures(GITextureType textureType);
3639

Editor/Mono/GUIView.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ protected Panel panel
3636
{
3737
if (m_Panel == null)
3838
{
39-
UXMLEditorFactories.RegisterAll();
4039
m_Panel = UIElementsUtility.FindOrCreatePanel(this, ContextType.Editor, DataWatchService.sharedInstance);
4140
m_Panel.cursorManager = m_CursorManager;
4241
m_Panel.contextualMenuManager = s_ContextualMenuManager;

Editor/Mono/Inspector/LightingSettingsInspector.cs

Lines changed: 109 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ static class Styles
6363
public static readonly GUIContent GINotEnabledInfo = EditorGUIUtility.TrTextContent("Lightmapping settings are currently disabled. Enable Baked Global Illumination or Realtime Global Illumination to display these settings.");
6464
public static readonly GUIContent CastShadowsProgressiveGPUWarning = EditorGUIUtility.TrTextContent("Cast Shadows is forced to 'On' when using the GPU lightmapper (Preview), it will be supported in a later version. Use the CPU lightmapper instead if you need this functionality.");
6565
public static readonly GUIContent ReceiveShadowsProgressiveGPUWarning = EditorGUIUtility.TrTextContent("Receive Shadows is forced to 'On' when using the GPU lightmapper (Preview), it will be supported in a later version. Use the CPU lightmapper instead if you need this functionality.");
66+
public static readonly GUIContent OpenPreview = EditorGUIUtility.TrTextContent("Open Preview");
67+
68+
public static readonly GUIStyle OpenPreviewStyle = EditorStyles.objectFieldThumb.name + "LightmapPreviewOverlay";
69+
70+
public static readonly int PreviewPadding = 30;
71+
public static readonly int PreviewWidth = 104;
6672
}
6773

6874
bool m_ShowChartingSettings = true;
6975
bool m_ShowLightmapSettings = true;
70-
bool m_ShowBakedLM = false;
71-
bool m_ShowRealtimeLM = false;
76+
bool m_ShowBakedLM = true;
77+
bool m_ShowRealtimeLM = true;
7278

7379
SerializedObject m_SerializedObject;
7480
SerializedObject m_GameObjectsSerializedObject;
@@ -240,13 +246,8 @@ public void RenderMeshSettings(bool showLightmapSettings)
240246
{
241247
EditorGUI.indentLevel += 1;
242248

243-
m_ShowBakedLM = EditorGUILayout.Foldout(m_ShowBakedLM, Styles.Atlas, true);
244-
if (m_ShowBakedLM)
245-
ShowAtlasGUI(m_Renderers[0].GetInstanceID());
246-
247-
m_ShowRealtimeLM = EditorGUILayout.Foldout(m_ShowRealtimeLM, Styles.RealtimeLM, true);
248-
if (m_ShowRealtimeLM)
249-
ShowRealtimeLMGUI(m_Renderers[0]);
249+
ShowAtlasGUI(m_Renderers[0].GetInstanceID());
250+
ShowRealtimeLMGUI(m_Renderers[0]);
250251

251252
EditorGUI.indentLevel -= 1;
252253
}
@@ -312,13 +313,8 @@ public void RenderTerrainSettings()
312313
if (GUI.enabled && m_Terrains.Length == 1 && m_Terrains[0].terrainData != null)
313314
ShowBakePerformanceWarning(m_Terrains[0]);
314315

315-
m_ShowBakedLM = EditorGUILayout.Foldout(m_ShowBakedLM, Styles.Atlas, true);
316-
if (m_ShowBakedLM)
317-
ShowAtlasGUI(m_Terrains[0].GetInstanceID());
318-
319-
m_ShowRealtimeLM = EditorGUILayout.Foldout(m_ShowRealtimeLM, Styles.RealtimeLM, true);
320-
if (m_ShowRealtimeLM)
321-
ShowRealtimeLMGUI(m_Terrains[0]);
316+
ShowAtlasGUI(m_Terrains[0].GetInstanceID());
317+
ShowRealtimeLMGUI(m_Terrains[0]);
322318

323319
m_SerializedObject.ApplyModifiedProperties();
324320
}
@@ -413,44 +409,29 @@ void ShowAtlasGUI(int instanceID)
413409
if (m_CachedBakedTexture.texture == null)
414410
return;
415411

416-
EditorGUI.indentLevel += 1;
412+
m_ShowBakedLM = EditorGUILayout.Foldout(m_ShowBakedLM, Styles.Atlas, true);
417413

418-
GUILayout.BeginHorizontal();
419-
GUILayout.Space(30);
420-
421-
Rect rect = GUILayoutUtility.GetRect(100, 100, EditorStyles.objectField);
414+
if (!m_ShowBakedLM)
415+
return;
422416

423-
EditorGUI.Toggle(rect, false, EditorStyles.objectFieldThumb);
417+
EditorGUI.indentLevel += 1;
424418

425-
if (rect.Contains(Event.current.mousePosition))
426-
{
427-
Object actualTargetObject = m_CachedBakedTexture.texture;
428-
Component com = actualTargetObject as Component;
419+
GUILayout.BeginHorizontal();
429420

430-
if (com)
431-
actualTargetObject = com.gameObject;
421+
DrawLightmapPreview(m_CachedBakedTexture.texture, false, instanceID);
432422

433-
if (Event.current.clickCount == 2)
434-
LightmapPreviewWindow.CreateLightmapPreviewWindow(m_Renderers[0].GetInstanceID(), false, false);
435-
else if (Event.current.clickCount == 1)
436-
EditorGUI.PingObjectOrShowPreviewOnClick(actualTargetObject, GUILayoutUtility.GetLastRect());
437-
}
423+
GUILayout.BeginVertical();
438424

439-
if (Event.current.type == EventType.Repaint)
440-
{
441-
rect = EditorStyles.objectFieldThumb.padding.Remove(rect);
442-
EditorGUI.DrawPreviewTexture(rect, m_CachedBakedTexture.texture);
443-
}
425+
GUILayout.Label(Styles.AtlasIndex.text + ": " + m_LightmapIndex.intValue.ToString());
426+
GUILayout.Label(Styles.AtlasTilingX.text + ": " + m_LightmapTilingOffsetX.floatValue.ToString());
427+
GUILayout.Label(Styles.AtlasTilingY.text + ": " + m_LightmapTilingOffsetY.floatValue.ToString());
428+
GUILayout.Label(Styles.AtlasOffsetX.text + ": " + m_LightmapTilingOffsetZ.floatValue.ToString());
429+
GUILayout.Label(Styles.AtlasOffsetY.text + ": " + m_LightmapTilingOffsetW.floatValue.ToString());
444430

431+
GUILayout.EndVertical();
445432
GUILayout.FlexibleSpace();
446433
GUILayout.EndHorizontal();
447434

448-
EditorGUILayout.LabelField(Styles.AtlasIndex, GUIContent.Temp(m_LightmapIndex.intValue.ToString()));
449-
EditorGUILayout.LabelField(Styles.AtlasTilingX, GUIContent.Temp(m_LightmapTilingOffsetX.floatValue.ToString()));
450-
EditorGUILayout.LabelField(Styles.AtlasTilingY, GUIContent.Temp(m_LightmapTilingOffsetY.floatValue.ToString()));
451-
EditorGUILayout.LabelField(Styles.AtlasOffsetX, GUIContent.Temp(m_LightmapTilingOffsetZ.floatValue.ToString()));
452-
EditorGUILayout.LabelField(Styles.AtlasOffsetY, GUIContent.Temp(m_LightmapTilingOffsetW.floatValue.ToString()));
453-
454435
bool showProgressiveInfo = isPrefabAsset || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten);
455436

456437
if (showProgressiveInfo && Unsupported.IsDeveloperMode())
@@ -467,19 +448,32 @@ void ShowAtlasGUI(int instanceID)
467448
LightmapEditorSettings.GetPVRAtlasInstanceOffset(instanceID, out atlasInstanceOffset);
468449
EditorGUILayout.LabelField(Styles.PVRAtlasInstanceOffset, GUIContent.Temp(atlasInstanceOffset.ToString()));
469450
}
470-
471451
EditorGUI.indentLevel -= 1;
452+
453+
GUILayout.Space(5);
472454
}
473455

474456
void ShowRealtimeLMGUI(Terrain terrain)
475457
{
458+
Hash128 inputSystemHash;
459+
if (terrain == null || !LightmapEditorSettings.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128())
460+
return; // early return since we don't have any lightmaps for it
461+
462+
if (!UpdateRealtimeTexture(inputSystemHash, terrain.GetInstanceID()))
463+
return;
464+
465+
m_ShowRealtimeLM = EditorGUILayout.Foldout(m_ShowRealtimeLM, Styles.RealtimeLM, true);
466+
467+
if (!m_ShowRealtimeLM)
468+
return;
469+
476470
EditorGUI.indentLevel += 1;
477471

478-
Hash128 inputSystemHash;
479-
if (terrain != null && LightmapEditorSettings.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash))
480-
{
481-
ShowRealtimeLightmapPreview(inputSystemHash);
482-
}
472+
GUILayout.BeginHorizontal();
473+
474+
DrawLightmapPreview(m_CachedRealtimeTexture.texture, true, terrain.GetInstanceID());
475+
476+
GUILayout.BeginVertical();
483477

484478
// Resolution of the system.
485479
int width, height;
@@ -489,34 +483,56 @@ void ShowRealtimeLMGUI(Terrain terrain)
489483
var str = width.ToString() + "x" + height.ToString();
490484
if (numChunksInX > 1 || numChunksInY > 1)
491485
str += string.Format(" ({0}x{1} chunks)", numChunksInX, numChunksInY);
492-
EditorGUILayout.LabelField(Styles.RealtimeLMResolution, GUIContent.Temp(str));
486+
GUILayout.Label(Styles.RealtimeLMResolution.text + ": " + str);
493487
}
494488

489+
GUILayout.EndVertical();
490+
GUILayout.FlexibleSpace();
491+
GUILayout.EndHorizontal();
492+
495493
EditorGUI.indentLevel -= 1;
494+
495+
GUILayout.Space(5);
496496
}
497497

498498
void ShowRealtimeLMGUI(Renderer renderer)
499499
{
500+
Hash128 inputSystemHash;
501+
if (renderer == null || !LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128())
502+
return; // early return since we don't have any lightmaps for it
503+
504+
if (!UpdateRealtimeTexture(inputSystemHash, renderer.GetInstanceID()))
505+
return;
506+
507+
m_ShowRealtimeLM = EditorGUILayout.Foldout(m_ShowRealtimeLM, Styles.RealtimeLM, true);
508+
509+
if (!m_ShowRealtimeLM)
510+
return;
511+
500512
EditorGUI.indentLevel += 1;
501513

502-
Hash128 inputSystemHash = new Hash128();
503-
if (renderer != null && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash))
504-
{
505-
ShowRealtimeLightmapPreview(inputSystemHash);
506-
}
514+
GUILayout.BeginHorizontal();
515+
516+
DrawLightmapPreview(m_CachedRealtimeTexture.texture, true, renderer.GetInstanceID());
517+
518+
GUILayout.BeginVertical();
507519

508520
int instWidth, instHeight;
509521
if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight))
510522
{
511-
EditorGUILayout.LabelField(Styles.RealtimeLMInstanceResolution, GUIContent.Temp(instWidth.ToString() + "x" + instHeight.ToString()));
523+
GUILayout.Label(Styles.RealtimeLMInstanceResolution.text + ": " + instWidth.ToString() + "x" + instHeight.ToString());
512524
}
513525

514526
int width, height;
515527
if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height))
516528
{
517-
EditorGUILayout.LabelField(Styles.RealtimeLMResolution, GUIContent.Temp(width.ToString() + "x" + height.ToString()));
529+
GUILayout.Label(Styles.RealtimeLMResolution.text + ": " + width.ToString() + "x" + height.ToString());
518530
}
519531

532+
GUILayout.EndVertical();
533+
GUILayout.FlexibleSpace();
534+
GUILayout.EndHorizontal();
535+
520536
if (Unsupported.IsDeveloperMode())
521537
{
522538
Hash128 instanceHash;
@@ -535,12 +551,14 @@ void ShowRealtimeLMGUI(Renderer renderer)
535551
}
536552

537553
EditorGUI.indentLevel -= 1;
554+
555+
GUILayout.Space(5);
538556
}
539557

540-
void ShowRealtimeLightmapPreview(Hash128 inputSystemHash)
558+
bool UpdateRealtimeTexture(Hash128 inputSystemHash, int instanceId)
541559
{
542560
if (inputSystemHash == new Hash128())
543-
return;
561+
return false;
544562

545563
Hash128 contentHash = LightmapVisualizationUtility.GetRealtimeGITextureHash(inputSystemHash, GITextureType.Irradiance);
546564

@@ -549,35 +567,51 @@ void ShowRealtimeLightmapPreview(Hash128 inputSystemHash)
549567
m_CachedRealtimeTexture = LightmapVisualizationUtility.GetRealtimeGITexture(inputSystemHash, GITextureType.Irradiance);
550568

551569
if (m_CachedRealtimeTexture.texture == null)
552-
return;
570+
return false;
553571

554-
GUILayout.BeginHorizontal();
555-
GUILayout.Space(30);
572+
return true;
573+
}
556574

557-
Rect rect = GUILayoutUtility.GetRect(100, 100, EditorStyles.objectField);
575+
private void DrawLightmapPreview(Texture2D texture, bool realtimeLightmap, int instanceId)
576+
{
577+
GUILayout.Space(Styles.PreviewPadding);
558578

559-
EditorGUI.Toggle(rect, false, EditorStyles.objectFieldThumb);
579+
int previewWidth = Styles.PreviewWidth - 4; // padding
560580

561-
if (rect.Contains(Event.current.mousePosition))
581+
Rect rect = GUILayoutUtility.GetRect(previewWidth, previewWidth, EditorStyles.objectField);
582+
Rect buttonRect = new Rect(rect.xMax - 70, rect.yMax - 14, 70, 14);
583+
584+
if (Event.current.type == EventType.MouseDown)
562585
{
563-
Object actualTargetObject = m_CachedRealtimeTexture.texture;
564-
Component com = actualTargetObject as Component;
586+
if ((buttonRect.Contains(Event.current.mousePosition) && Event.current.clickCount == 1) ||
587+
(rect.Contains(Event.current.mousePosition) && Event.current.clickCount == 2))
588+
{
589+
LightmapPreviewWindow.CreateLightmapPreviewWindow(instanceId, realtimeLightmap, false);
590+
}
591+
else if (rect.Contains(Event.current.mousePosition) && Event.current.clickCount == 1)
592+
{
593+
Object actualTargetObject = texture;
594+
Component com = actualTargetObject as Component;
565595

566-
if (com)
567-
actualTargetObject = com.gameObject;
596+
if (com)
597+
actualTargetObject = com.gameObject;
568598

569-
if (Event.current.clickCount == 2)
570-
LightmapPreviewWindow.CreateLightmapPreviewWindow(m_Renderers[0].GetInstanceID(), true, false);
599+
EditorGUI.PingObjectOrShowPreviewOnClick(actualTargetObject, rect);
600+
}
571601
}
572602

603+
EditorGUI.Toggle(rect, false, EditorStyles.objectFieldThumb);
604+
573605
if (Event.current.type == EventType.Repaint)
574606
{
575607
rect = EditorStyles.objectFieldThumb.padding.Remove(rect);
576-
EditorGUI.DrawPreviewTexture(rect, m_CachedRealtimeTexture.texture);
608+
EditorGUI.DrawPreviewTexture(rect, texture);
609+
610+
Styles.OpenPreviewStyle.Draw(rect, Styles.OpenPreview, false, false, false, false);
577611
}
578612

579-
GUILayout.FlexibleSpace();
580-
GUILayout.EndHorizontal();
613+
float spacing = Mathf.Max(5.0f, EditorGUIUtility.labelWidth - Styles.PreviewPadding - Styles.PreviewWidth);
614+
GUILayout.Space(spacing);
581615
}
582616

583617
static bool HasNormals(Renderer renderer)

0 commit comments

Comments
 (0)