Currently, online is loading the world map through API Key, and offline is generating terrain through .tpkx file and displaying it in Unity's Scene.
For road alignment,
I want to draw a 2D plane line and project it on the terrain to return the elevation value of each point,
and I want to check the elevation value of the corresponding location with latitude/longitude or x, z coordinates on Unity.
RayCast has accuracy issues when the displayed map is wide, so I am considering it as an alternative.
Is there a function that can be used in ArcGIS Maps SDK for Unity?
The solution will depend on what you want to do with the line and elevation points. For example, is it purely for display? In which case, you probably want to simply have the line draped on the elevation surface.
Or do you need the elevation values for another purpose, in which case you might consider using our (beta) elevation service to get the best resolution value for each point/location: Elevation service (beta) | Esri Developer REST APIs documentation.
A couple of things to consider:
I've build something similar because you cannot rely on external services. Arcgis has no real out-of-the-box solution so making a custom system worked for me.
Your raycasts are inaccurate because of the different LOD of the tiles which comes from difference ArcGisCamera positions & settings so how do you combat that?
Have a system update their raycast result and update your line at runtime. You don't need to do this every frame and there is a lot of optimization you can do like only executing this update logic if you're close.