Skip to content

Commit 7c2a973

Browse files
author
Unity Technologies
committed
Unity 2017.1.0p3 C# reference source code
1 parent d5d0cbb commit 7c2a973

File tree

9 files changed

+145
-28
lines changed

9 files changed

+145
-28
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ static private UndoPropertyModification[] ProcessRotationModifications(IAnimatio
320320
}
321321
else
322322
{
323-
AddRotationKey(state, binding, type, previousValue.eulerAngles, currentValue.eulerAngles);
323+
Vector3 eulerAngles = target.GetLocalEulerAngles(RotationOrder.OrderZXY);
324+
325+
Vector3 previousEulerAngles = AnimationUtility.GetClosestEuler(previousValue, eulerAngles, RotationOrder.OrderZXY);
326+
Vector3 currentEulerAngles = AnimationUtility.GetClosestEuler(currentValue, eulerAngles, RotationOrder.OrderZXY);
327+
328+
AddRotationKey(state, binding, type, previousEulerAngles, currentEulerAngles);
324329
}
325330
}
326331

Editor/Mono/Collab/Softlocks/SoftlockViewController.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private void RegisterDrawDelegates()
8989
UnregisterDrawDelegates();
9090
ObjectListArea.postAssetIconDrawCallback += Instance.DrawProjectBrowserGridUI;
9191
ObjectListArea.postAssetLabelDrawCallback += Instance.DrawProjectBrowserListUI;
92+
AssetsTreeViewGUI.postAssetLabelDrawCallback += Instance.DrawSingleColumnProjectBrowserUI;
9293
Editor.OnPostIconGUI += Instance.DrawInspectorUI;
9394
GameObjectTreeViewGUI.OnPostHeaderGUI += Instance.DrawSceneUI;
9495
}
@@ -225,8 +226,7 @@ private void DrawInspectorUI(Editor editor, Rect drawRect)
225226
}
226227

227228
// Assigned callback to ObjectListArea.OnPostAssetDrawDelegate.
228-
// Draws either overtop of the project browser asset (when in grid view) or
229-
// at the rightside when in list view.
229+
// Draws either overtop of the project browser asset (when in grid view).
230230
private void DrawProjectBrowserGridUI(Rect iconRect, string assetGUID, bool isListMode)
231231
{
232232
if (isListMode || !HasSoftlocks(assetGUID))
@@ -243,21 +243,43 @@ private void DrawProjectBrowserGridUI(Rect iconRect, string assetGUID, bool isLi
243243
}
244244
}
245245

246+
// Should draw only in listMode and expects 'drawRect' to be the designed space for the icon,
247+
// and not the entire row.
246248
private bool DrawProjectBrowserListUI(Rect drawRect, string assetGUID, bool isListMode)
247249
{
248-
if (!HasSoftlocks(assetGUID))
250+
if (!isListMode || !HasSoftlocks(assetGUID))
249251
{
250252
return false;
251253
}
252254

255+
// center icon.
256+
Rect iconRect = drawRect;
257+
iconRect.width = drawRect.height;
258+
iconRect.x = (float)Math.Round(drawRect.center.x - (iconRect.width / 2F));
259+
return DrawInProjectBrowserListMode(iconRect, assetGUID);
260+
}
261+
262+
// Expects 'drawRect' to be the available width of the row.
263+
private bool DrawSingleColumnProjectBrowserUI(Rect drawRect, string assetGUID)
264+
{
265+
if (ProjectBrowser.s_LastInteractedProjectBrowser.IsTwoColumns() || !HasSoftlocks(assetGUID))
266+
{
267+
return false;
268+
}
269+
270+
Rect iconRect = drawRect;
271+
iconRect.width = drawRect.height;
272+
float spacingFromEnd = (iconRect.width / 2F);
273+
iconRect.x = (float)Math.Round(drawRect.xMax - iconRect.width - spacingFromEnd);
274+
return DrawInProjectBrowserListMode(iconRect, assetGUID);
275+
}
276+
277+
private bool DrawInProjectBrowserListMode(Rect iconRect, string assetGUID)
278+
{
253279
Texture icon = SoftLockUIData.GetIconForSection(SoftLockUIData.SectionEnum.ProjectBrowser);
254280
bool didDraw = false;
255281
if (icon != null)
256282
{
257-
// center icon.
258-
Rect iconRect = drawRect;
259-
iconRect.width = drawRect.height;
260-
iconRect.x = (float)Math.Round(drawRect.center.x - (iconRect.width / 2F));
261283
DrawIconWithTooltips(iconRect, icon, assetGUID);
262284
didDraw = true;
263285
}

Editor/Mono/EditorGUI.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,10 +2078,22 @@ internal static int DelayedIntFieldInternal(Rect position, GUIContent label, int
20782078
string intStr = EditorGUI.DelayedTextFieldInternal(position, id, label, oldVal.ToString(), s_AllowedCharactersForInt, style);
20792079
if (EditorGUI.EndChangeCheck())
20802080
{
2081-
if (int.TryParse(intStr, out newVal) && newVal != oldVal)
2081+
if (int.TryParse(intStr, out newVal))
20822082
{
2083-
value = newVal;
2084-
GUI.changed = true;
2083+
if (newVal != oldVal)
2084+
{
2085+
value = newVal;
2086+
GUI.changed = true;
2087+
}
2088+
}
2089+
else
2090+
{
2091+
newVal = ExpressionEvaluator.Evaluate<int>(intStr);
2092+
if (newVal != oldVal)
2093+
{
2094+
value = newVal;
2095+
GUI.changed = true;
2096+
}
20852097
}
20862098
}
20872099
return newVal;

Editor/Mono/GUI/TreeView/AssetsTreeViewGUI.cs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using UnityEngine;
88
using UnityEditorInternal.VersionControl;
99
using UnityEditor.VersionControl;
10+
using System.Collections.Generic;
11+
using UnityEngine.Assertions;
1012

1113
namespace UnityEditor
1214
{
@@ -18,10 +20,16 @@ internal class AssetsTreeViewGUI : TreeViewGUI
1820
internal delegate void OnAssetIconDrawDelegate(Rect iconRect, string guid);
1921
internal static event OnAssetIconDrawDelegate postAssetIconDrawCallback = null;
2022

23+
internal delegate bool OnAssetLabelDrawDelegate(Rect drawRect, string guid);
24+
internal static event OnAssetLabelDrawDelegate postAssetLabelDrawCallback = null;
25+
26+
private static IDictionary<int, string> s_GUIDCache = null;
27+
2128
public AssetsTreeViewGUI(TreeViewController treeView)
2229
: base(treeView)
2330
{
2431
iconOverlayGUI += OnIconOverlayGUI;
32+
labelOverlayGUI += OnLabelOverlayGUI;
2533
k_TopRowMargin = 4f;
2634
}
2735

@@ -131,19 +139,47 @@ private void OnIconOverlayGUI(TreeViewItem item, Rect overlayRect)
131139
{
132140
if (postAssetIconDrawCallback != null && AssetDatabase.IsMainAsset(item.id))
133141
{
134-
string path = AssetDatabase.GetAssetPath(item.id);
135-
string guid = AssetDatabase.AssetPathToGUID(path);
142+
string guid = GetGUIDForInstanceID(item.id);
136143
postAssetIconDrawCallback(overlayRect, guid);
137144
}
138145

139146
// Draw vcs icons
140147
if (s_VCEnabled && AssetDatabase.IsMainAsset(item.id))
141148
{
142-
string path = AssetDatabase.GetAssetPath(item.id);
143-
string guid = AssetDatabase.AssetPathToGUID(path);
149+
string guid = GetGUIDForInstanceID(item.id);
144150
ProjectHooks.OnProjectWindowItem(guid, overlayRect);
145151
}
146152
}
153+
154+
private void OnLabelOverlayGUI(TreeViewItem item, Rect labelRect)
155+
{
156+
if (postAssetLabelDrawCallback != null && AssetDatabase.IsMainAsset(item.id))
157+
{
158+
string guid = GetGUIDForInstanceID(item.id);
159+
postAssetLabelDrawCallback(labelRect, guid);
160+
}
161+
}
162+
163+
// Returns a previously stored GUID for the given ID,
164+
// else retrieves it from the asset database and stores it.
165+
private static string GetGUIDForInstanceID(int instanceID)
166+
{
167+
if (s_GUIDCache == null)
168+
{
169+
s_GUIDCache = new Dictionary<int, string>();
170+
}
171+
172+
string GUID = null;
173+
if (!s_GUIDCache.TryGetValue(instanceID, out GUID))
174+
{
175+
string path = AssetDatabase.GetAssetPath(instanceID);
176+
GUID = AssetDatabase.AssetPathToGUID(path);
177+
Assert.IsTrue(!string.IsNullOrEmpty(GUID));
178+
s_GUIDCache.Add(instanceID, GUID);
179+
}
180+
181+
return GUID;
182+
}
147183
}
148184

149185

Editor/Mono/GUI/TreeView/TreeViewGUI.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal abstract class TreeViewGUI : ITreeViewGUI
2020
public float iconRightPadding { get; set; }
2121
public float iconTotalPadding { get { return iconLeftPadding + iconRightPadding; } }
2222
public System.Action<TreeViewItem, Rect> iconOverlayGUI { get; set; } // Rect includes iconLeftPadding and iconRightPadding
23+
public System.Action<TreeViewItem, Rect> labelOverlayGUI { get; set; }
2324

2425
private bool m_AnimateScrollBarOnExpandCollapse = true;
2526

@@ -382,6 +383,11 @@ protected virtual void OnContentGUI(Rect rect, int row, TreeViewItem item, strin
382383
if (icon != null)
383384
rect.xMin += k_IconWidth + iconTotalPadding + k_SpaceBetweenIconAndText;
384385
lineStyle.Draw(rect, label, false, false, selected, focused);
386+
387+
if (labelOverlayGUI != null)
388+
{
389+
labelOverlayGUI(item, rect);
390+
}
385391
}
386392

387393
// Ping Item

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Unity 2017.1.0p2 C# reference source code
1+
## Unity 2017.1.0p3 C# reference source code
22

33
The C# part of the Unity engine and editor source code.
44
May be used for reference purposes only.

Runtime/WebRequestWWW/UWRWWW.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ public string error
124124
get
125125
{
126126
if (!_uwr.isDone)
127-
return "";
127+
return null;
128128
if (_uwr.isNetworkError)
129129
return _uwr.error;
130130
if (_uwr.responseCode >= 400)
131131
return string.Format("{0} {1}", _uwr.responseCode, GetStatusCodeName(_uwr.responseCode));
132-
return "";
132+
return null;
133133
}
134134
}
135135

artifacts/generated/common/editor/CollabBindings.gen.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,28 @@ public ProgressInfo GetJobProgress(int jobId)
141141
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
142142
extern public ProgressInfo GetJobProgressByType (int jobType) ;
143143

144-
public void CancelJob(int jobId)
144+
[uei.ExcludeFromDocs]
145+
public void CancelJob (int jobId) {
146+
bool forceCancel = false;
147+
CancelJob ( jobId, forceCancel );
148+
}
149+
150+
public void CancelJob(int jobId, [uei.DefaultValue("false")] bool forceCancel )
145151
{
146-
CancelJobByType(jobId);
152+
CancelJobByType(jobId, forceCancel);
147153
}
154+
148155

149156

150157
[UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration
151158
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
152-
extern public void CancelJobByType (int jobType) ;
159+
extern public void CancelJobByType (int jobType, [uei.DefaultValue("false")] bool forceCancel ) ;
160+
161+
[uei.ExcludeFromDocs]
162+
public void CancelJobByType (int jobType) {
163+
bool forceCancel = false;
164+
CancelJobByType ( jobType, forceCancel );
165+
}
153166

154167
[UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration
155168
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]

artifacts/generated/common/runtime/TextureBindings.gen.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,50 +973,61 @@ private RenderTextureDescriptor GetDescriptor () {
973973
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
974974
private extern static void INTERNAL_CALL_GetDescriptor (RenderTexture self, out RenderTextureDescriptor value);
975975
[uei.ExcludeFromDocs]
976+
public static RenderTexture GetTemporary (int width, int height, int depthBuffer , RenderTextureFormat format , RenderTextureReadWrite readWrite , int antiAliasing , RenderTextureMemoryless memorylessMode ) {
977+
VRTextureUsage vrUsage = VRTextureUsage.None;
978+
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode, vrUsage );
979+
}
980+
981+
[uei.ExcludeFromDocs]
976982
public static RenderTexture GetTemporary (int width, int height, int depthBuffer , RenderTextureFormat format , RenderTextureReadWrite readWrite , int antiAliasing ) {
983+
VRTextureUsage vrUsage = VRTextureUsage.None;
977984
RenderTextureMemoryless memorylessMode = RenderTextureMemoryless.None;
978-
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode );
985+
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode, vrUsage );
979986
}
980987

981988
[uei.ExcludeFromDocs]
982989
public static RenderTexture GetTemporary (int width, int height, int depthBuffer , RenderTextureFormat format , RenderTextureReadWrite readWrite ) {
990+
VRTextureUsage vrUsage = VRTextureUsage.None;
983991
RenderTextureMemoryless memorylessMode = RenderTextureMemoryless.None;
984992
int antiAliasing = 1;
985-
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode );
993+
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode, vrUsage );
986994
}
987995

988996
[uei.ExcludeFromDocs]
989997
public static RenderTexture GetTemporary (int width, int height, int depthBuffer , RenderTextureFormat format ) {
998+
VRTextureUsage vrUsage = VRTextureUsage.None;
990999
RenderTextureMemoryless memorylessMode = RenderTextureMemoryless.None;
9911000
int antiAliasing = 1;
9921001
RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default;
993-
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode );
1002+
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode, vrUsage );
9941003
}
9951004

9961005
[uei.ExcludeFromDocs]
9971006
public static RenderTexture GetTemporary (int width, int height, int depthBuffer ) {
1007+
VRTextureUsage vrUsage = VRTextureUsage.None;
9981008
RenderTextureMemoryless memorylessMode = RenderTextureMemoryless.None;
9991009
int antiAliasing = 1;
10001010
RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default;
10011011
RenderTextureFormat format = RenderTextureFormat.Default;
1002-
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode );
1012+
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode, vrUsage );
10031013
}
10041014

10051015
[uei.ExcludeFromDocs]
10061016
public static RenderTexture GetTemporary (int width, int height) {
1017+
VRTextureUsage vrUsage = VRTextureUsage.None;
10071018
RenderTextureMemoryless memorylessMode = RenderTextureMemoryless.None;
10081019
int antiAliasing = 1;
10091020
RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default;
10101021
RenderTextureFormat format = RenderTextureFormat.Default;
10111022
int depthBuffer = 0;
1012-
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode );
1023+
return GetTemporary ( width, height, depthBuffer, format, readWrite, antiAliasing, memorylessMode, vrUsage );
10131024
}
10141025

1015-
public static RenderTexture GetTemporary(int width, int height, [uei.DefaultValue("0")] int depthBuffer , [uei.DefaultValue("RenderTextureFormat.Default")] RenderTextureFormat format , [uei.DefaultValue("RenderTextureReadWrite.Default")] RenderTextureReadWrite readWrite , [uei.DefaultValue("1")] int antiAliasing , [uei.DefaultValue("RenderTextureMemoryless.None")] RenderTextureMemoryless memorylessMode )
1026+
public static RenderTexture GetTemporary(int width, int height, [uei.DefaultValue("0")] int depthBuffer , [uei.DefaultValue("RenderTextureFormat.Default")] RenderTextureFormat format , [uei.DefaultValue("RenderTextureReadWrite.Default")] RenderTextureReadWrite readWrite , [uei.DefaultValue("1")] int antiAliasing , [uei.DefaultValue("RenderTextureMemoryless.None")] RenderTextureMemoryless memorylessMode , [uei.DefaultValue("VRTextureUsage.None")] VRTextureUsage vrUsage )
10161027
{
10171028
var desc = new RenderTextureDescriptor(width, height);
10181029
desc.depthBufferBits = depthBuffer;
1019-
desc.vrUsage = VRTextureUsage.None;
1030+
desc.vrUsage = vrUsage;
10201031
desc.colorFormat = format;
10211032
desc.sRGB = (readWrite != RenderTextureReadWrite.Linear);
10221033
desc.msaaSamples = antiAliasing;
@@ -1053,6 +1064,14 @@ private static RenderTexture GetTemporary_Internal (RenderTextureDescriptor desc
10531064
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
10541065
extern private static void Internal_SetHeight (RenderTexture mono, int width) ;
10551066

1067+
[UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration
1068+
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
1069+
extern private static VRTextureUsage Internal_GetVRUsage (RenderTexture mono) ;
1070+
1071+
[UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration
1072+
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
1073+
extern private static void Internal_SetVRUsage (RenderTexture mono, VRTextureUsage vrUsage) ;
1074+
10561075
[UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration
10571076
[System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)]
10581077
extern private static void Internal_SetSRGBReadWrite (RenderTexture mono, bool sRGB) ;
@@ -1065,6 +1084,10 @@ private static RenderTexture GetTemporary_Internal (RenderTextureDescriptor desc
10651084
override public int height { get { return Internal_GetHeight(this); } set { Internal_SetHeight(this, value); } }
10661085

10671086

1087+
1088+
public VRTextureUsage vrUsage { get { return Internal_GetVRUsage(this); } set { Internal_SetVRUsage(this, value); }}
1089+
1090+
10681091
public extern int depth
10691092
{
10701093
[UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration

0 commit comments

Comments
 (0)