Topic: sharing markers with PUN

Trying to think of correct approach for creating/sharing OnlineMaps markers via Photon networking or similar.

At the moment I am using Photon.Instantiate to create the prefab/resource over the network. Of course OnlineMaps doesn'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) ?

I didn't use OnlineMaps to instantiate a prefab, as I thought Photon must do it.

Otherwise do I need to create a marker in OnlineMaps, and at same time Photon.instantiate  a separate object to handle network side of things, and link/sync both together manually somehow?

Re: sharing markers with PUN

Online Maps does not know about Photon.
Photon does not know about Online Maps.
You need to fix this misunderstanding.

You can create GameObject or via Photon or via Online Maps.
Both methods have advantages and disadvantages.

Yes, of course you can make markers from existing GameObjects.
Example:

using UnityEngine;

public class CreateMarkerFromGameObject:MonoBehaviour
{
    private GameObject sphere;

    private void OnGUI()
    {
        if (sphere != null && GUILayout.Button("Create marker from sphere"))
        {
            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);
    }
}

But, keep in mind that when Photon destroys GameObject, the marker will exist.
You will need to find and remove it.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.