Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Message icon:

shortcuts: hit alt+s to submit/post or alt+p to preview

Topic Summary

Posted by: Kronnect
« on: August 14, 2019, 08:20:09 AM »

Yes, you should be able to attach small files. In this case you can zip the project and upload somewhere like Google Drive and send me a pm with the download link.
Posted by: Fierde
« on: August 14, 2019, 08:05:35 AM »

Ok, how do I attach a file to a reply? Clicking on "Attachments and other options" just gives me "return to this topic" and "don't use smileys".
Posted by: Kronnect
« on: August 14, 2019, 07:21:08 AM »

The texture coordinates are invariant of object scale.
At this point, since it's custom development, I could help if you can provide a sample scene that includes what you have achieved so far.
Posted by: Fierde
« on: August 14, 2019, 06:53:25 AM »

OK, that's done. A couple more questions.
If I have my WorldMapGlobe object scaled up, how should I augment my calculation?
Also, I'm using texturecoordinates, but I see no point at which to actually pass in the texture I want to use. So how would Unity know that I want my minimap texture highlighted?
Posted by: Kronnect
« on: August 14, 2019, 03:47:55 AM »

The raycast hit point property is in world space coordinates.
The Conversion.ConvertToTextureCoordinates API expects a position in local coordinates.
Try passing map.transform.InverseTransformPoint(hitXX.point) instead.
Posted by: Fierde
« on: August 13, 2019, 11:41:09 AM »

Are you guys able to guide me in the right direction?
Posted by: Fierde
« on: August 09, 2019, 07:24:47 AM »

OK, after trying this out by myself, I've gotten to about this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MiniMap : MonoBehaviour
    // Start is called before the first frame update
    Ray topLeft;
    Ray topRight;
    Ray botRight;
    Ray botLeft;
    RaycastHit hitTL;
    RaycastHit hitTR;
    RaycastHit hitBL;
    RaycastHit hitBR;
    Vector3 textureTR;
    Vector3 textureTL;
    Vector3 textureBR;
    Vector3 textureBL;
    void Start()

    // Update is called once per frame
    void Update()
        topLeft = Camera.main.ViewportPointToRay(;
        topRight = Camera.main.ViewportPointToRay(new Vector3(1, 0, 0));
        botRight = Camera.main.ViewportPointToRay(new Vector3(1, 1, 0));
        botLeft = Camera.main.ViewportPointToRay(new Vector3(0, 1, 0));

    private void OnGUI()
        if (Physics.Raycast(topLeft, out hitTL) && Physics.Raycast(topRight, out hitTR) && Physics.Raycast(botRight, out hitBR) && Physics.Raycast(botLeft, out hitBL))
            textureTR = WPM.Conversion.ConvertToTextureCoordinates(hitTR.point, 1, 1);
            textureTL = WPM.Conversion.ConvertToTextureCoordinates(hitTL.point, 1, 1);
            textureBR = WPM.Conversion.ConvertToTextureCoordinates(hitBR.point, 1, 1);
            Debug.Log(textureTR + " " + textureTL + " " + textureBR);
            DrawQuad(new Rect(textureTL.x, textureTR.x, textureTR.y, textureBR.y),;

    void DrawQuad(Rect position, Color color)
        Texture2D texture = new Texture2D(1, 1);
        texture.SetPixel(0, 0, color);
        texture.Apply(); = texture;
        GUI.Box(position, GUIContent.none);

Obviously this isn't quite correct, I'm just not sure what to do next.
Posted by: Kronnect
« on: August 08, 2019, 11:55:10 AM »

The texture coordinates are standard (in the 0..1 range). But the local map positions in WMSK are in the -0.5 .. 0.5 range, so depending on the methdo you use, you may need to add 0.5f to them to map those coordinates to 0..1 tex coords.
Posted by: Fierde
« on: August 08, 2019, 11:48:07 AM »

Awesome, thanks for the help. I think option B would work best for what I'm going for. One question though: if I'm using he Conversion methods, would I have to make the minimap a WMSK object, or will those methods work with the texture coordinates for any sprite with a texture?
Posted by: Kronnect
« on: August 08, 2019, 10:48:22 AM »

That's a quite interesting challenge. I'd say there're two scenarios: a) the globe fits within screen edges, b) only a portion of the globe is visible.
In a) case, you could raycast from the center of screen to the globe and convert that hit position into a lat/lon or texture coordinate, knowing that half of sphere is visible (an extents of 180 degrees lat/lon from the raycast hit).
In b) case, you could raycast the corners of the camera frustum and convert the sphere positions of raycast hit into lat/lon or texture coordinates using the Conversion.xxxx methods.

There's a method called GetVisibleCountries which returns which countries are visible from the camera. Another option is to use this method and compute the enclosing rectangle of all country areas (country.rect2D).
Posted by: Fierde
« on: August 07, 2019, 01:25:17 PM »

I'm trying to implement a system where, while hovering the main camera around the globe, there will be a flat 2D minimap that highlights whatever is captured in the main camera's viewport corresponding to the 3D Globe. So, the flat minimap shows the entire earth, but whatever section of the globe the main camera is looking at will be highlighted on the minimap with a red rectangle or something. Of course, the highlight will get smaller as the main camera zooms into the globe, thus seeing less of the earth. I don't really have any idea how to project the 3D position of the camera around the globe to a corresponding 2D position on the flat map. If anyone thinks this is an interesting or feasible idea, feel free to provide answers/insight. Thanks!