Skip to content

Commit 0a1cdae

Browse files
author
Unity Technologies
committed
Unity 6000.1.0b3 C# reference source code
1 parent 2940f42 commit 0a1cdae

File tree

50 files changed

+1923
-1004
lines changed

Some content is hidden

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

50 files changed

+1923
-1004
lines changed

Editor/Mono/Commands/GOCreationCommands.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private static void SetGameObjectParent(GameObject go, Transform parentTransform
3838
ObjectFactory.AddComponent<RectTransform>(go);
3939
}
4040

41-
internal static void Place(GameObject go, GameObject parent, bool ignoreSceneViewPosition = true)
41+
internal static void Place(GameObject go, GameObject parent, bool ignoreSceneViewPosition = true, bool alignWithSceneCamera = false)
4242
{
4343
Transform defaultObjectTransform = SceneView.GetDefaultParentObjectIfSet();
4444

@@ -64,7 +64,21 @@ internal static void Place(GameObject go, GameObject parent, bool ignoreSceneVie
6464
if (placeObjectsAtWorldOrigin)
6565
go.transform.position = Vector3.zero;
6666
else if (ignoreSceneViewPosition)
67-
SceneView.PlaceGameObjectInFrontOfSceneView(go);
67+
{
68+
if(alignWithSceneCamera && go.TryGetComponent<Camera>(out var cam))
69+
{
70+
if (SceneView.lastActiveSceneView?.in2DMode == true)
71+
{
72+
// set 2D mode specific camera defaults
73+
cam.orthographic = true;
74+
cam.transform.position = new Vector3(0f, 0f, -10f);
75+
}
76+
77+
SceneView.AlignCameraWithView(cam);
78+
}
79+
else
80+
SceneView.PlaceGameObjectInFrontOfSceneView(go);
81+
}
6882

6983
StageUtility.PlaceGameObjectInCurrentStage(go); // may change parent
7084
}
@@ -455,7 +469,7 @@ static void CreateLine(MenuCommand menuCommand)
455469
static void CreateCamera(MenuCommand menuCommand)
456470
{
457471
var parent = menuCommand.context as GameObject;
458-
Place(ObjectFactory.CreateGameObject("Camera", typeof(Camera), typeof(AudioListener)), parent);
472+
Place(ObjectFactory.CreateGameObject("Camera", typeof(Camera), typeof(AudioListener)), parent, alignWithSceneCamera: true);
459473
}
460474
}
461475
}

Editor/Mono/InternalEditorUtility.bindings.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,17 @@ public static void SaveToSerializedFileAndForget(Object[] obj, string path, bool
292292
[FreeFunction("InternalEditorUtilityBindings::HierarchyWindowDrag")]
293293
extern public static DragAndDropVisualMode HierarchyWindowDrag([Unmarshalled] HierarchyProperty property, HierarchyDropFlags dropMode, Transform parentForDraggedObjects, bool perform);
294294

295+
public static DragAndDropVisualMode HierarchyWindowDragByID(int dropTargetInstanceID, HierarchyDropFlags dropMode, Transform parentForDraggedObjects, bool perform)
296+
{
297+
// place at scene pivot unless we have Pref for placing at root or we dont have a scene view
298+
Vector3 worldPosition = Vector3.zero;
299+
if (!GOCreationCommands.s_PlaceObjectsAtWorldOrigin.value && SceneView.lastActiveSceneView != null)
300+
worldPosition = SceneView.lastActiveSceneView.pivot;
301+
302+
return HierarchyWindowDragByID(dropTargetInstanceID, worldPosition, dropMode, parentForDraggedObjects, perform);
303+
}
295304
[FreeFunction("InternalEditorUtilityBindings::HierarchyWindowDragByID")]
296-
extern public static DragAndDropVisualMode HierarchyWindowDragByID(int dropTargetInstanceID, HierarchyDropFlags dropMode, Transform parentForDraggedObjects, bool perform);
305+
extern internal static DragAndDropVisualMode HierarchyWindowDragByID(int dropTargetInstanceID, Vector3 worldPosition, HierarchyDropFlags dropMode, Transform parentForDraggedObjects, bool perform);
297306

298307
[FreeFunction("InternalEditorUtilityBindings::InspectorWindowDrag")]
299308
extern internal static DragAndDropVisualMode InspectorWindowDrag(Object[] targets, bool perform);

Editor/Mono/SceneView/SceneView.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,36 @@ internal static void PlaceGameObjectInFrontOfSceneView(GameObject go)
16061606
view.MoveToView(go.transform);
16071607
}
16081608
}
1609+
internal static void AlignCameraWithView(Camera camera)
1610+
{
1611+
if (s_SceneViews.Count >= 1)
1612+
{
1613+
var view = lastActiveSceneView;
1614+
if (view == null) return;
1615+
1616+
if (view.in2DMode)
1617+
{
1618+
var sceneCamera = view.camera;
1619+
1620+
var worldMiddle = sceneCamera.ScreenToWorldPoint(new Vector4(0f, 0f, 0f, 3f));
1621+
var invMiddle = sceneCamera.transform.InverseTransformPoint(worldMiddle);
1622+
1623+
var worldTop = sceneCamera.ScreenToWorldPoint(new Vector3(0f, sceneCamera.pixelHeight, 0.3f));
1624+
var invTop = sceneCamera.transform.InverseTransformPoint(worldTop);
1625+
1626+
var size = Mathf.Abs((invTop - invMiddle).y / 2f);
1627+
1628+
camera.orthographicSize = size;
1629+
1630+
var pos = sceneCamera.transform.position;
1631+
1632+
// maintain current camera z pos as it is either a user set value, or the default from GOCreationCommands
1633+
camera.transform.position = new Vector3(pos.x, pos.y, camera.transform.position.z);
1634+
}
1635+
else
1636+
view.AlignWithView(camera.transform);
1637+
}
1638+
}
16091639

16101640
internal static Camera GetLastActiveSceneViewCamera()
16111641
{
@@ -3903,6 +3933,7 @@ public void MoveToView()
39033933
{
39043934
FixNegativeSize();
39053935
Vector3 dif = pivot - Tools.handlePosition;
3936+
if (m_2DMode) dif.z = 0f;
39063937

39073938
Undo.RecordObjects(Selection.transforms, "Move to view");
39083939

@@ -3914,7 +3945,15 @@ public void MoveToView()
39143945

39153946
public void MoveToView(Transform target)
39163947
{
3917-
target.position = pivot;
3948+
var pos = pivot;
3949+
if (m_2DMode) pos.z = target.position.z;
3950+
target.position = pos;
3951+
}
3952+
3953+
internal void AlignWithView(Transform target)
3954+
{
3955+
target.position = camera.transform.position;
3956+
target.rotation = camera.transform.rotation;
39183957
}
39193958

39203959
internal bool IsGameObjectInThisSceneView(GameObject gameObject)

Editor/Mono/UnityConnect/CloudProjectSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public static string accessToken
4242
}
4343
}
4444

45+
/// <summary>
46+
/// Get the service authentication token used for the Service Gateway apis
47+
/// </summary>
48+
/// <param name="cancellationToken"></param>
4549
public static Task<string> GetServiceTokenAsync(CancellationToken cancellationToken = default)
4650
=> ServiceToken.Instance.GetServiceTokenAsync(accessToken, cancellationToken);
4751

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
namespace UnityEditor.Connect
6+
{
7+
class OrganizationRequestResponse
8+
{
9+
public string LegacyId { get; internal set; }
10+
public string Id { get; }
11+
public string GenesisId { get; }
12+
public string Name { get; }
13+
public string Role { get; }
14+
15+
public OrganizationRequestResponse(
16+
string legacyId,
17+
string id,
18+
string genesisId,
19+
string name,
20+
string role = "")
21+
{
22+
LegacyId = legacyId;
23+
Id = id;
24+
GenesisId = genesisId;
25+
Name = name;
26+
Role = role;
27+
}
28+
}
29+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
namespace UnityEditor.Connect
6+
{
7+
class ProjectRequestResponse
8+
{
9+
public string Id { get; }
10+
public string GenesisId { get; }
11+
public string Name { get; }
12+
public string Coppa { get; }
13+
public string OrganizationName { get; internal set; }
14+
public string OrganizationLegacyId { get; internal set; }
15+
public string OrganizationId { get; }
16+
public string OrganizationGenesisId { get; }
17+
18+
public ProjectRequestResponse(
19+
string id,
20+
string genesisId,
21+
string name,
22+
string coppa,
23+
string organizationLegacyId,
24+
string organizationId,
25+
string organizationGenesisId)
26+
{
27+
Id = id;
28+
GenesisId = genesisId;
29+
Name = name;
30+
Coppa = coppa;
31+
OrganizationLegacyId = organizationLegacyId;
32+
OrganizationId = organizationId;
33+
OrganizationGenesisId = organizationGenesisId;
34+
}
35+
}
36+
}
37+

0 commit comments

Comments
 (0)