Skip to content

Commit

Permalink
ビルドエラー修正
Browse files Browse the repository at this point in the history
  • Loading branch information
linoal committed Oct 16, 2023
1 parent 933c34f commit ee5315b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public void SwitchLodIcon(int lod, bool isCheck)

foreach (var view in this.viewDict)
{
#if UNITY_EDITOR
view.Value?.CalculateLodViewParam(SceneView.lastActiveSceneView.camera, showLods);
#endif
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion Runtime/CityImport/AreaSelector/SceneObjs/AreaLodView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public class AreaLodView

#if UNITY_EDITOR
private static readonly string IconDirPath = PathUtil.SdkPathToAssetPath("Images/AreaSelect");
#endif

#if UNITY_EDITOR
private static readonly float MaxIconWidth = 50 * EditorGUIUtility.pixelsPerPoint;
#else
private static readonly float MaxIconWidth = 50;
#endif

/// <summary> 範囲選択画面に表示する画像名 </summary>
Expand Down Expand Up @@ -72,7 +77,11 @@ public AreaLodView(PackageToLodDict packageToLodDict, Vector3 meshCodeUnityPosit
public static void Init()
{
iconDict = LoadIconFiles();
#if UNITY_EDITOR
monitorDpiScalingFactor = EditorGUIUtility.pixelsPerPoint;
#else
monitorDpiScalingFactor = 1.0f;
#endif
}

public void DrawHandles(Camera camera, HashSet<int> showLods)
Expand Down Expand Up @@ -180,7 +189,11 @@ public void CalculateLodViewParam(Camera camera, ICollection<int> showLods)
offsetVec.x = xOffset * monitorDpiScalingFactor;
offsetVec.y = yOffset * monitorDpiScalingFactor;
var iconPos = camera.ScreenToWorldPoint(camera.WorldToScreenPoint(meshCodeCenterUnityPos) + offsetVec);
var style = new GUIStyle(EditorStyles.label)
var style = new GUIStyle(
#if UNITY_EDITOR
EditorStyles.label
#endif
)
{
fixedHeight = iconWidth,
fixedWidth = iconWidth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ private void OnDrawGizmos()
private void UpdateMousePressedStatus()
{
// 左クリックのMouseUpのイベントを受け取るためにデフォルトコントロールに追加
#if UNITY_EDITOR
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
#endif

var currentEvent = Event.current;
if (currentEvent == null)
Expand Down Expand Up @@ -174,14 +176,18 @@ private void UpdateMousePressedStatus()
{
foreach (var meshCodeGizmoDrawer in this.meshCodeDrawers)
{
#if UNITY_EDITOR
meshCodeGizmoDrawer.ToggleSelectArea(currentEvent.mousePosition);
#endif
}
}
else if (this.isLeftMouseButtonMoved || this.isLeftMouseAndShiftButtonMoved)
{
foreach (var meshCodeGizmoDrawer in this.meshCodeDrawers)
{
#if UNITY_EDITOR
meshCodeGizmoDrawer.SetSelectArea(this.areaSelectionGizmoDrawer.AreaSelectionMin, this.areaSelectionGizmoDrawer.AreaSelectionMax, this.isLeftMouseButtonMoved);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ public void SetUp()

public void SetTrackingStartedPosition(Vector2 mousePosition)
{
#if UNITY_EDITOR
var ray = HandleUtility.GUIPointToWorldRay(mousePosition);
if (Physics.Raycast(ray, out var hit, RayCastMaxDistance))
{
this.trackingStartedMousePosition = hit.point;
}
#endif
}

public void UpdateAreaSelectionGizmo(Vector2 mousePosition, bool isLeftMouseButtonMoved)
{
#if UNITY_EDITOR
var ray = HandleUtility.GUIPointToWorldRay(mousePosition);
if (Physics.Raycast(ray, out var hit, RayCastMaxDistance))
{
Expand All @@ -53,6 +56,7 @@ public void UpdateAreaSelectionGizmo(Vector2 mousePosition, bool isLeftMouseButt
this.AreaSelectionMax = new Vector3((float)maxX, CenterPositionY, (float)maxZ);
Init(centerPosition, size, this.meshCode);
}
#endif
}

public void ClearAreaSelectionGizmo()
Expand Down

0 comments on commit ee5315b

Please sign in to comment.