Giter Site home page Giter Site logo

esri / arcgis-maps-sdk-unity-samples Goto Github PK

View Code? Open in Web Editor NEW
98.0 12.0 45.0 873.95 MB

Sample code for the ArcGIS Maps SDK for Unity.

Home Page: https://developers.arcgis.com/unity-sdk/

License: Apache License 2.0

C# 63.95% ShaderLab 30.01% HLSL 5.07% Shell 0.27% Python 0.70%
unity charp game-engine samples arcgis-maps-sdk-for-unity arcgis esri sdk

arcgis-maps-sdk-unity-samples's Introduction

arcgis-maps-sdk-unity-samples

image

Here is a Unity project containing a set of samples showing you how to accomplish various things using the combined features of Unity and the ArcGIS Maps SDK for Unity. The main branch is configured to work with our most recent release (1.5.0) if you want to use the sample repo with an older release check out the corresponding tag of the sample repo, git checkout 1.0.0 for the sample repo that worked with our 1.0.0 release.

Note

This repository is made up of two separate Unity projects. If you would like to see the samples made for regular use such as Feature Layer and Routing, please use and set up the sample_project. If you are interested in XR Samples such as the Virtual Reality Sample and the XR version of our Table Top Sample, please use and set up the sample_xr. Both projects may be used and set up simultaneously, but they do not contain the same samples.

Requirements for Sample Project

  • Computer running Windows or macOS
  • The Unity project was created with 2021.3.24 LTS but is compatible with any version of 2021.3 LTS and also works with 2022.3 LTS
  • ArcGISMaps SDK for Unity

Requirements for XR Sample Project

  • Computer running Windows (OpenXR is not supported on macOS)
  • The Unity project was created with 2023.3.19 LTS but is compatible with any version of 2022.3 LTS
  • ArcGISMaps SDK for Unity
  • A VR Headset and the necessary software to run through Desktop Mode

Features

  • Feature service REST API - See how to query a feature service to create game objects in Unity located at real-world positions.
  • Geocoding - Search for an address or click on the surface to get the address of that location.
  • HitTest - Visualize individual Buildings ID's from a 3D Object Scene Layer.
  • Line of sight - See how to check line of sight between two objects in Unity.
  • Material By Attribute - Apply materials to 3DObject Scene layer based on specific attributes.
  • Measure - Click on the map to get real-world distances between points.
  • Routing - See how to query Esri's routing service to get the shortest path between two points and visualize that route in Unity.
  • Stream Layer - See how to use web sockets to connect to an Esri real-time service to update game objects locations in real-time.
  • Third Person Controller - Explore from the perspective of a third person camera following a controllable character.
  • Real Time Weather Query - Query the current weather in a city using the feature layer query work flow.

Features in XR Sample Project

  • VRSample - See how to configure the camera to visualize content on a VR device and move the camera with VR locomotion.
  • XRTableTop - See how to configure the camera to visualize a tabletop map on a VR device and control the map with VR controllers and hand tracking.

Instructions

  1. Clone this repo.

  2. Refer to the ArcGIS Maps SDK for Unity's documentation on getting started on how to download Unity and the ArcGIS Maps SDK for Unity.

  3. Open the project in Unity ignoring the errors when prompted to enter Safe Mode.

  4. Use the package manager to import the .tarball downloaded in step 2.

    image

  5. Import the samples. These samples include some components necessary for this repo to function including the ArcGIS Camera Controller component.

  6. Launch Unity and open the SampleViewer level (it should open by default).

  7. In the hierarchy select the SampleSwitcher Game Object and then in the inspector set your API Key. You can learn more about API keys and Accounts in the Mapping APIs and location services guide.

  8. (Optional) If you want to be able to open the .cs files in this project and have IntelliSense recognize variable correctly, in Unity navigate to Edit -> Preferences -> External Tools -> Generate .csproj files for 'local tarball

Requirements

Resources

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

Licensing

Copyright 2023 Esri.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

arcgis-maps-sdk-unity-samples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arcgis-maps-sdk-unity-samples's Issues

Stream layer sample: ClientWebSocket.ReceiveAsync may need to loop over multiple chunks

var result = await wsClient.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);

Should probably be implemented as a loop in order to make sure all the payload for a message is gathered.
More info here: https://stackoverflow.com/questions/23773407/a-websockets-receiveasync-method-does-not-await-the-entire-message

Google Place Api

In this projrct got Google Place Api? If got how to use it in Unity?

'ArcGISPoint' does not contain a definition for 'SetZ

Error - Assets\SampleViewer\Samples\FeatureLayer\StadiumInfo.cs(101,26): error CS1061: 'ArcGISPoint' does not contain a definition for 'SetZ' and no accessible extension method 'SetZ' accepting a first argument of type 'ArcGISPoint' could be found (are you missing a using directive or an assembly reference?)

The associated script can not be loaded.

Having issues trying to get the samples working. I see this message in the SampleSwitcher.

image

I also see these messages in the console

image

I opened the samples_project in Unity Hub by clicking Open Add Project from disk, then added the ArcGIS SDK, imported assets and then try to add credentials in Sample Switcher but see the error about the script not being able to load.

Missing DLL after Esri SDK package import

After adding the Esri SDK (through the package manager) I get the following error. I'm using Unity 2022.2.12

DllNotFoundException: libruntimecore assembly: type: member:(null)
Esri.GameEngine.View.ArcGISView..ctor (Esri.GameEngine.ArcGISGameEngineType gameEngineType, Esri.GameEngine.MapView.ArcGISGlobeModel globeModel) (at ./Library/PackageCache/com.esri.arcgis-maps-sdk@d1c578d68416/SDK/API/GameEngine/View/ArcGISView.cs:38)
Esri.ArcGISMapsSDK.Components.ArcGISMapComponent.get_View () (at ./Library/PackageCache/com.esri.arcgis-maps-sdk@d1c578d68416/SDK/Components/ArcGISMapComponent.cs:337)
Esri.ArcGISMapsSDK.Components.ArcGISMapComponent.SyncPositionWithHPRoot () (at ./Library/PackageCache/com.esri.arcgis-maps-sdk@d1c578d68416/SDK/Components/ArcGISMapComponent.cs:864)
Esri.ArcGISMapsSDK.Components.ArcGISMapComponent.Update () (at ./Library/PackageCache/com.esri.arcgis-maps-sdk@d1c578d68416/SDK/Components/ArcGISMapComponent.cs:525)

Change Map Layers Order Not Work

When Change Layers Like :
MapComponent.Layers = MapComponent.Layers = new List { layer1,layer2};
To
MapComponent.Layers = MapComponent.Layers = new List { layer2,layer1};
Sometimes Not Work ;

But After Reset Enable It Works :
MapComponent.enabled=false;
MapComponent.enabled=true;

Example for Oculus Quest Standalone

HI,
Is there an example to use the SDK in standalone mode for Oculus Quest?
I'm trying to convert the example but I'm having some problems.
Thank you
Luca

Third Person Character Sample for Unity

Wondering if a sample similar to the "Explore with Third Person Character" in the Unreal SDK could be added for Unity?

I've been playing around with the Unity built in Third person template - it would be really cool to somehow import an Integrated Mesh Layer (.slpk) and have the character walk around in it.

Can you tell me why it's taking so long to initialize

The initialization of the map is too slow, the initialization is successful only about 4s, and before the initialization is successful, the longitude and latitude conversion algorithm will be called abnormally

public static Vector3 GetUnityPosFromLatlon(ArcGISPoint latLon)
{
var cartesianPosition = arcGISMapComponent.View.GeographicToWorld(latLon);
Vector3 result = hPRoot.TransformPoint(cartesianPosition).ToVector3();

// Check for NaN values
if (float.IsNaN(result.x) || float.IsNaN(result.y) || float.IsNaN(result.z))
{
Debug.LogWarning("GetUnityPosFromLatlon returned NaN. Returning default value.");
return Vector3.zero; // Return a default value (0, 0, 0) in case of NaN
}

return result; // Return the calculated result

}

public static ArcGISPoint GetLatLonFromUnityPos(Vector3 vec)
{

var worldPosition = hPRoot.InverseTransformPoint(vec.ToDouble3());
ArcGISPoint result = arcGISMapComponent.View.WorldToGeographic(worldPosition);
if (double.IsNaN(result.X) || double.IsNaN(result.Y) || double.IsNaN(result.Z))
{
Debug.LogWarning("GetLatLonFromUnityPos returned NaN. Returning default value.");
return new ArcGISPoint(0,0,0); // Return a default value (0, 0, 0) in case of NaN
}
return result;

}

Can you tell me why it's taking so long to initialize

Error switching to samples with global scenes

Most times when using the sample switcher to switch to the FeatureLayer or Component samples these errors will be displayed in the console and the map data will not be loaded.

Switching the scenes to Local will not trigger these errors.
image

Support for Unity Render Streaming Package

I'm working on an application that leverages the Unity Render Streaming package - https://docs.unity3d.com/Packages/[email protected]/manual/index.html

This allows you to interact with the game in a web browser, while the actual game runs elsewhere. I'm trying to get the Third Person example working but running into some issues. I'm able to get it displayed in the browser using the Receiver Sample https://docs.unity3d.com/Packages/[email protected]/manual/tutorial.html

but the controls are not working in the browser. Any ideas?

EDIT Recorded a video demonstrating this issue
https://youtu.be/xVFZl4g7gBw

Screen is Black with Constant XR Toolkit Error

Tried following the installation instructions but cant get the samples working. Wish these were included in standard package.

Screen remains black and there is error from XRInteraction toolkit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.