Created
March 23, 2020 23:36
-
-
Save icywind/f84b5faa3c60d8efdcaa3339920f6e17 to your computer and use it in GitHub Desktop.
Method to draw the dots from the given position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int dotCount = 0; | |
/// <summary> | |
/// | |
/// </summary> | |
/// <param name="pos">Screen Position</param> | |
void DrawDot(Vector2 pos) | |
{ | |
if (anchorGO == null) | |
{ | |
anchorGO = new GameObject(); | |
anchorGO.transform.SetParent(referenceObject.transform.parent); | |
anchorGO.transform.position = Vector3.zero; | |
anchorGO.transform.localScale = Vector3.one; | |
anchorGO.name = "DrawAnchor"; | |
} | |
// DeNormalize the position and adjust to passed camera | |
Vector3 location = DeNormalizedPosition(pos, renderCam); | |
GameObject go = GameObject.Instantiate(DrawPrefab, location, Quaternion.identity); | |
go.transform.SetParent(anchorGO.transform); | |
go.transform.localScale = DotScale * Vector3.one; | |
go.layer = (int)CameraLayer.IGNORE_RAYCAST; | |
go.name = "dot " + dotCount; | |
dotCount++; | |
Debug.LogFormat("{0} pos:{1} => : {2} ", go.name, pos, location); | |
Renderer renderer = go.GetComponent<Renderer>(); | |
if (renderer != null) | |
{ | |
Material mat = renderer.material; | |
if (mat != null) | |
{ | |
mat.color = DrawColor; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment