/// <summary> /// Load items and component settings from JSON /// </summary> /// <param name="json">JSON item</param> public void LoadSettings(OnlineMapsJSONItem json) { OnlineMapsJSONItem jitems = json["items"]; RemoveAll(); foreach (OnlineMapsJSONItem jitem in jitems) { OnlineMapsMarker marker = new OnlineMapsMarker(); double mx = jitem.ChildValue <double>("longitude"); double my = jitem.ChildValue <double>("latitude"); marker.SetPosition(mx, my); marker.range = jitem.ChildValue <OnlineMapsRange>("range"); marker.label = jitem.ChildValue <string>("label"); marker.texture = OnlineMapsUtils.GetObject(jitem.ChildValue <int>("texture")) as Texture2D; marker.align = (OnlineMapsAlign)jitem.ChildValue <int>("align"); marker.rotation = jitem.ChildValue <float>("rotation"); marker.enabled = jitem.ChildValue <bool>("enabled"); Add(marker); } OnlineMapsJSONItem jsettings = json["settings"]; defaultTexture = OnlineMapsUtils.GetObject(jsettings.ChildValue <int>("defaultTexture")) as Texture2D; defaultAlign = (OnlineMapsAlign)jsettings.ChildValue <int>("defaultAlign"); defaultScale = jsettings.ChildValue <float>("defaultScale"); allowAddMarkerByM = jsettings.ChildValue <bool>("allowAddMarkerByM"); }
public void LoadSettings(OnlineMapsJSONItem json) { OnlineMapsJSONItem jitems = json["items"]; RemoveAll(); foreach (OnlineMapsJSONItem jitem in jitems) { OnlineMapsMarker3D marker = new OnlineMapsMarker3D(); double mx = jitem.ChildValue <double>("longitude"); double my = jitem.ChildValue <double>("latitude"); marker.SetPosition(mx, my); marker.range = jitem.ChildValue <OnlineMapsRange>("range"); marker.label = jitem.ChildValue <string>("label"); marker.prefab = OnlineMapsUtils.GetObject(jitem.ChildValue <int>("prefab")) as GameObject; marker.rotationY = jitem.ChildValue <float>("rotationY"); marker.scale = jitem.ChildValue <float>("scale"); marker.enabled = jitem.ChildValue <bool>("enabled"); Add(marker); } (json["settings"] as OnlineMapsJSONObject).DeserializeObject(this); }