<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Showing attributes in ArcGIS Maps SDK for Unity Questions</title>
    <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1257945#M435</link>
    <description>&lt;P&gt;Hello dun82,&lt;/P&gt;&lt;P&gt;Matt mentioned using&lt;SPAN&gt;&amp;nbsp;the AttributeProcessor to store all the attributes, I tried to do that but I could only read string data.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2023 13:48:32 GMT</pubDate>
    <dc:creator>MazenTalaat</dc:creator>
    <dc:date>2023-02-14T13:48:32Z</dc:date>
    <item>
      <title>Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1195198#M55</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Is there a way to select an object and show its attributes?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jul 2022 13:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1195198#M55</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2022-07-23T13:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1195474#M58</link>
      <description>&lt;P&gt;Hi Mazen, did you see the ArcGIS Hit test sample in our plugin? That shows you how to show the Object ID. After that you can reference our Feature Layer sample in the samples repo to see how to query additional information from the Feature Service's rest end point&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 16:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1195474#M58</guid>
      <dc:creator>Matt_Nelson</dc:creator>
      <dc:date>2022-07-25T16:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1197800#M63</link>
      <description>&lt;P&gt;Hello Matt,&lt;/P&gt;&lt;P&gt;Thanks for your reply, I did try the&amp;nbsp;&lt;SPAN&gt;ArcGIS Hit test sample and got the featureId but it is different from Object ID. (screenshots 1 and 2)&lt;BR /&gt;I also noticed that the&amp;nbsp;featureId changes depending on the number of objects seen by the camera. (screenshots 2 and 3)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Did I misunderstand something?&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jul 2022 21:13:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1197800#M63</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2022-07-31T21:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1199195#M73</link>
      <description>&lt;P&gt;So what you are seeing is that the feature ID is different based off the LOD that we are showing. In other words this is different than the Object ID.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 22:08:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1199195#M73</guid>
      <dc:creator>Matt_Nelson</dc:creator>
      <dc:date>2022-08-03T22:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1199209#M74</link>
      <description>&lt;P&gt;From what I understand,&amp;nbsp;&lt;SPAN&gt;ArcGIS Hit test sample shows the&amp;nbsp;featureId which is&amp;nbsp;based off the LOD and the&amp;nbsp;Feature Layer sample returns all the features with their attributes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So how can I relate between the clicked object and its attributes without having the Object ID?&lt;BR /&gt;Maybe by comparing the latitude and longitude of the hit object?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 22:43:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1199209#M74</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2022-08-03T22:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1203558#M102</link>
      <description>&lt;P&gt;Hi Mazen,&lt;BR /&gt;&lt;BR /&gt;Haven't forgot about this question. So there was actually a bug where we were returning the FeatureIndex not the FeatureID in this result. The next release will contain this fix. IF you need it now I can recommend updating the function to be this&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;public Physics.ArcGISRaycastHit GetArcGISRaycastHit(RaycastHit raycastHit)&lt;BR /&gt;{&lt;BR /&gt;Physics.ArcGISRaycastHit output;&lt;BR /&gt;output.featureId = -1;&lt;BR /&gt;output.featureIndex = -1;&lt;BR /&gt;output.layer = null;&lt;/P&gt;&lt;P&gt;var arcGISRendererComponent = rendererGO.GetComponent&amp;lt;ArcGISRendererComponent&amp;gt;();&lt;/P&gt;&lt;P&gt;if (raycastHit.collider != null &amp;amp;&amp;amp; arcGISRendererComponent != null)&lt;BR /&gt;{&lt;BR /&gt;var sceneComponent = arcGISRendererComponent.GetSceneComponentByGameObject(raycastHit.collider.gameObject);&lt;/P&gt;&lt;P&gt;if (sceneComponent != null)&lt;BR /&gt;{&lt;BR /&gt;output.featureIndex = Physics.RaycastHelpers.GetFeatureIndexByTriangleIndex(raycastHit.collider.gameObject, raycastHit.triangleIndex);&lt;BR /&gt;output.layer = View.Map?.FindLayerById(sceneComponent.LayerId);&lt;/P&gt;&lt;P&gt;if (sceneComponent.Material.NativeMaterial.HasTexture("_FeatureIds"))&lt;BR /&gt;{&lt;BR /&gt;// gets the feature ID&lt;BR /&gt;var featureIds = (Texture2D)sceneComponent.Material.NativeMaterial.GetTexture("_FeatureIds");&lt;/P&gt;&lt;P&gt;var width = featureIds.width;&lt;BR /&gt;int y = (int)Mathf.Floor(output.featureIndex / width);&lt;BR /&gt;int x = output.featureIndex - y * width;&lt;/P&gt;&lt;P&gt;var color = featureIds.GetPixel(x, y);&lt;BR /&gt;var scaledColor = new Vector4(255f * color.r, 255f * color.g, 255f * color.b, 255f * color.a);&lt;BR /&gt;var shift = new Vector4(1, 0x100, 0x10000, 0x1000000);&lt;BR /&gt;scaledColor.Scale(shift);&lt;/P&gt;&lt;P&gt;output.featureId = (int)(scaledColor.x + scaledColor.y + scaledColor.z + scaledColor.w);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return output;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You will still have one more issue though, with that being the difference between some SceneServers. Some have an associated FeatureLayer resource which you can just use the query operation on. However if your SceneServer contains cached attributes it is significantly more complicated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If you share the service you are using I can help identify what it is.&lt;BR /&gt;&lt;BR /&gt;IF it ends up being a cached service I can try to explain how you can use the AttributeProcessor to store all the attributes you need in a map for your later use. But we will be creating a better solution for this as well so I'll hold off on explaining this unless we end up confirming you are working with a cached SceneServer&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 23:15:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1203558#M102</guid>
      <dc:creator>Matt_Nelson</dc:creator>
      <dc:date>2022-08-16T23:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1203732#M104</link>
      <description>&lt;P&gt;Hello Matt,&lt;/P&gt;&lt;P&gt;Thank you for your support, I will give it a try.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 14:25:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1203732#M104</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2022-08-17T14:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1227094#M251</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;I tried updating the function but kept getting errors because&amp;nbsp;featureIndex&amp;nbsp;wasn't defined, so my approach is as follows:&lt;/P&gt;&lt;P&gt;ArcGIS Pro side:&lt;BR /&gt;* I uploaded a&amp;nbsp;Scene Layer to show the 3D objects and Feature Layer to use the query operation on.&lt;BR /&gt;* The&amp;nbsp;Feature Layer has some&amp;nbsp;attributes like name, lon and lat.&lt;/P&gt;&lt;P&gt;Unity side:&lt;/P&gt;&lt;P&gt;1. I added the 3D layer to the scene and did the query operation while adding each feature attributes to a list.&lt;BR /&gt;2. When clicking a 3D object, I compare its location(lon, lat) with the location(lon, lat) in the list.&lt;BR /&gt;3. If the condition is true, I can break and get the rest of the attributes.&lt;/P&gt;&lt;P&gt;I still have one more issue, I can't get the location of the 3D object to be exactly the same as in the Feature layer every time so the comparison sometimes returns false in all iterations.&lt;/P&gt;&lt;P&gt;Here is how I get the location for the 3D object what I do:&lt;BR /&gt;I tried getting the ArcGISLocationComponent but it returns null, so&amp;nbsp;I got the&amp;nbsp;HPTransform.UniversePosition of the 3D object then converted it to ArcGISPoint by using arcGISMapComponent.View.WorldToGeographic( )&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 16:46:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1227094#M251</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2022-10-31T16:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1256395#M428</link>
      <description>&lt;P&gt;We get the featureId from v1.1.0 but is there a way to retrieve the attribute info from a 3DObject scene layer?&lt;/P&gt;&lt;P&gt;I searched the REST API but could not figure out a way to query this piece of info from a scene layer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 04:31:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1256395#M428</guid>
      <dc:creator>dun82</dc:creator>
      <dc:date>2023-02-09T04:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1257945#M435</link>
      <description>&lt;P&gt;Hello dun82,&lt;/P&gt;&lt;P&gt;Matt mentioned using&lt;SPAN&gt;&amp;nbsp;the AttributeProcessor to store all the attributes, I tried to do that but I could only read string data.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 13:48:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1257945#M435</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2023-02-14T13:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1258683#M437</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;SPAN&gt;dun82 for sharing your code in the other thread!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Finally, I managed to process the attributes and show the data, here are the used functions to do so.&lt;BR /&gt;(OBJECTID can be processed as Int)&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void Setup3DAttributes(ArcGIS3DObjectSceneLayer Layer)
    {
        if (Layer == null)
        {
            return;
        }
        var layerAttributes = ArcGISImmutableArray&amp;lt;String&amp;gt;.CreateBuilder();
        layerAttributes.Add("OBJECTID");

        var renderAttributeDescriptions = ArcGISImmutableArray&amp;lt;Esri.GameEngine.Attributes.ArcGISVisualizationAttributeDescription&amp;gt;.CreateBuilder();
        renderAttributeDescriptions.Add(new Esri.GameEngine.Attributes.ArcGISVisualizationAttributeDescription("IsBuildingOfInterest", Esri.GameEngine.Attributes.ArcGISVisualizationAttributeType.Float32));

        attributeProcessor = new Esri.GameEngine.Attributes.ArcGISAttributeProcessor();

        attributeProcessor.ProcessEvent += (ArcGISImmutableArray&amp;lt;Esri.GameEngine.Attributes.ArcGISAttribute&amp;gt; layerNodeAttributes, ArcGISImmutableArray&amp;lt;Esri.GameEngine.Attributes.ArcGISVisualizationAttribute&amp;gt; renderNodeAttributes) =&amp;gt;
        {
                var fidAttribute = layerNodeAttributes.At(0);
            /* Choose a function to process the data depending on the type
                ForEachInt64(fidAttribute, (Int64 element, Int32 index) =&amp;gt;
                {
                    //save in a list or print
                });

                ForEachString(fidAttribute, (string element, Int32 index) =&amp;gt;
                {
                    //save in a list or print
                });

                ForEachDouble(fidAttribute, (float element, Int32 index) =&amp;gt;
                {
                    //save in a list or print
                });
            */
        };
        Layer.SetAttributesToVisualize(layerAttributes.MoveToArray(), renderAttributeDescriptions.MoveToArray(), attributeProcessor);
    }

private void ForEachString(Esri.GameEngine.Attributes.ArcGISAttribute attribute, Action&amp;lt;string, Int32&amp;gt; predicate)
    {
        unsafe
        {
            var buffer = attribute.Data;
            var unsafePtr = NativeArrayUnsafeUtility.GetUnsafePtr(buffer);
            var metadata = (int*)unsafePtr;

            var count = metadata[0];

            // First integer = number of string on this array
            // Second integer = sum(strings length)
            // Next N-values (N = value of index 0 ) = Length of each string

            IntPtr stringPtr = (IntPtr)unsafePtr + (2 + count) * sizeof(int);

            for (var i = 0; i &amp;lt; count; ++i)
            {
                string element = null;

                // If the length of the string element is 0, it means the element is null
                if (metadata[2 + i] &amp;gt; 0)
                {
                    element = Marshal.PtrToStringAnsi(stringPtr, metadata[2 + i] - 1);
                }

                predicate(element, i);

                stringPtr += metadata[2 + i];
            }
        }
    }

    void ForEachInt64(Esri.GameEngine.Attributes.ArcGISAttribute attribute, Action&amp;lt;Int64, Int32&amp;gt; predicate)
    {
        unsafe
        {
            var buffer = attribute.Data;
            var unsafePtr = NativeArrayUnsafeUtility.GetUnsafePtr(buffer);
            var metadata = (int*)unsafePtr;
            var count = attribute.Data.Length/4;

            for (var i = 0; i &amp;lt; count; ++i)
            {
                predicate((Int64)metadata[i], i);
            }
        }
    }

    void ForEachDouble(Esri.GameEngine.Attributes.ArcGISAttribute attribute, Action&amp;lt;float, Int32&amp;gt; predicate)
    {
        unsafe
        {
            var buffer = attribute.Data;
            var unsafePtr = NativeArrayUnsafeUtility.GetUnsafePtr(buffer);
            var metadata = (double*)unsafePtr;
            var count = attribute.Data.Length / 8;

            for (var i = 0; i &amp;lt; count; ++i)
            {
                predicate((float)metadata[i], i);
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 20:45:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1258683#M437</guid>
      <dc:creator>MazenTalaat</dc:creator>
      <dc:date>2023-02-15T20:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1258814#M438</link>
      <description>&lt;P&gt;Thanks Mazen, but can you link the string data with the feature ID?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 09:30:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1258814#M438</guid>
      <dc:creator>dun82</dc:creator>
      <dc:date>2023-02-16T09:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1536174#M972</link>
      <description>&lt;P&gt;Hello MazenTalaat,&lt;/P&gt;&lt;P&gt;I also have a Unity project with ArcGIS layers and with a raycast i get a Feature ID (with the Hit test example). Now i want to make the attribuut values visible in a text field of that Feature. Is adding your code above enough to get this values?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RaycastHit hit;&lt;/P&gt;&lt;P&gt;if (Physics.Raycast(ray, out hit))&lt;BR /&gt;{&lt;BR /&gt;var arcGISRaycastHit = arcGISMapComponent.GetArcGISRaycastHit(hit);&lt;BR /&gt;var layer = arcGISRaycastHit.layer;&lt;BR /&gt;var featureId = arcGISRaycastHit.featureId;&lt;/P&gt;&lt;P&gt;if (layer != null &amp;amp;&amp;amp; featureId != -1)&lt;BR /&gt;{&lt;BR /&gt;featureText.text = featureId.ToString();&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Sat, 07 Sep 2024 09:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1536174#M972</guid>
      <dc:creator>WH1981</dc:creator>
      <dc:date>2024-09-07T09:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Showing attributes</title>
      <link>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1592733#M1058</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/549311"&gt;@MazenTalaat&lt;/a&gt;&amp;nbsp;, could you please help me on how you used the&amp;nbsp;&lt;SPAN&gt;AttributeProcessor&amp;nbsp;?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 14:34:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/showing-attributes/m-p/1592733#M1058</guid>
      <dc:creator>Ammar361421</dc:creator>
      <dc:date>2025-03-06T14:34:18Z</dc:date>
    </item>
  </channel>
</rss>

