<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — sharing markers with PUN]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=617&amp;type=atom" />
	<updated>2017-08-02T18:30:05Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=617</id>
		<entry>
			<title type="html"><![CDATA[Re: sharing markers with PUN]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2678#p2678" />
			<content type="html"><![CDATA[<p>Online Maps does not know about Photon.<br />Photon does not know about Online Maps.<br />You need to fix this misunderstanding.</p><p>You can create GameObject or via Photon or via Online Maps.<br />Both methods have advantages and disadvantages.</p><p>Yes, of course you can make markers from existing GameObjects.<br />Example:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class CreateMarkerFromGameObject:MonoBehaviour
{
    private GameObject sphere;

    private void OnGUI()
    {
        if (sphere != null &amp;&amp; GUILayout.Button(&quot;Create marker from sphere&quot;))
        {
            float scale = sphere.transform.localScale.x;

            OnlineMapsMarker3D marker = new OnlineMapsMarker3D(sphere);
            sphere.transform.parent = OnlineMaps.instance.transform;
            double lng, lat;
            OnlineMapsTileSetControl.instance.GetCoordsByWorldPosition(out lng, out lat, sphere.transform.position);
            marker.SetPosition(lng, lat);
            marker.scale = scale;
            OnlineMapsControlBase3D.instance.AddMarker3D(marker);
            marker.Update();

            sphere = null;
        }
    }

    private void Start()
    {
        sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        sphere.transform.position = OnlineMapsTileSetControl.instance.GetWorldPosition(OnlineMaps.instance.position);
        sphere.transform.localScale = new Vector3(50, 50, 50);
    }
}</code></pre></div><p>But, keep in mind that when Photon destroys GameObject, the marker will exist.<br />You will need to find and remove it.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-08-02T18:30:05Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2678#p2678</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[sharing markers with PUN]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2673#p2673" />
			<content type="html"><![CDATA[<p>Trying to think of correct approach for creating/sharing OnlineMaps markers via Photon networking or similar.</p><p>At the moment I am using Photon.Instantiate to create the prefab/resource over the network. Of course OnlineMaps doesn&#039;t know about this instance of gameobject at this point. Can we dynamically create a marker and assign the already instantiated gameobject (which will happen on each client) ?</p><p>I didn&#039;t use OnlineMaps to instantiate a prefab, as I thought Photon must do it.</p><p>Otherwise do I need to create a marker in OnlineMaps, and at same time Photon.instantiate&nbsp; a separate object to handle network side of things, and link/sync both together manually somehow?</p>]]></content>
			<author>
				<name><![CDATA[braden]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=499</uri>
			</author>
			<updated>2017-08-02T13:52:25Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2673#p2673</id>
		</entry>
</feed>
