ARTICLE AD BOX
I am working on a magic system in unity, where you draw glyphs on a scroll in order to cast spells. I made a function that allows me to test this directly through my PC, as it is easier than creating a build every time, and I cannot airlink. For some reason, the function that checks the drawn glyph is never called in the VR version. I know this has something to do with how they are called, but I've triple checked my code and the function should run, so I've come here for help.
Some code that might be of use:
The code for testing glyphs on PC:
[ContextMenu("Draw Glyph Manually")] public void drawGlyphManually() { DrawNewGlyph(); foreach (int index in manuallyDrawnGlyphIndexes) { AddGlyphPoint(inputPoints[index]); } CheckDrawnGlyph(); }The code that checks glyphs on VR:
public void SetCheckingState(bool state) { //This function is called both when the pen starts being used and when it stops being used, //with the state being set to it's respective value in each case //set the checkingForMagicPoints variable to the declared bool //so we only add points to the scroll when the pen is being used, and not when it's just being held or something checkingForMagicPoints = state; //check the new state of checkingForMagicPoints if (checkingForMagicPoints) { menuScript.logOnDevMenu("Started drawing!"); targetedScroll.DrawNewGlyph(); } else { //when the pen is no longer being used, send the list of hit points to the scroll //in order to check what glyph was drawn menuScript.logOnDevMenu("Stopped drawing!"); targetedScroll.CheckDrawnGlyph(); } }The CheckDrawnGlyph function:
public void CheckDrawnGlyph() { List<GameObject> glyphPoints = glyphs[glyphObjects[glyphObjects.Count - 1]]; //create a variable to store the glyph pattern List<int> glyphPattern = new List<int>(); for (int i = 0; i < glyphPoints.Count - 1; i++) { //record the change in index from every point to the next, or in other words, the pattern glyphPattern.Add(inputPoints.IndexOf(glyphPoints[i + 1]) - inputPoints.IndexOf(glyphPoints[i])); } //testing glyph List<int> triangle = new List<int> { 1, -scrollWidth - 1, scrollWidth }; //parse the pattern into a glyph if(glyphPattern.SequenceEqual(triangle)) { menuScript.logOnDevMenu("You drew a triangle!"); } else { menuScript.logOnDevMenu("Glyph not recognized"); menuScript.logOnDevMenu("Glyph pattern: " + string.Join(", ", glyphPattern)); } }I am happy to provide more info if necessary!
