Bug in WorldAnchorManager.AttachAnchor method
See original GitHub issueAccording to the documentation of the AttachAnchor(GameObject gameObjectToAnchor, string anchorName = null)
method, you can provide an anchor name or leave it empty. In case you leave it empty, the method uses the name of the GameObject. The documentation of the parameter anchorName
says, the name is a generated GUID.
<summary>
Attaches an anchor to the GameObject.
If the anchor store has an anchor with the specified name it will load the anchor,
otherwise a new anchor will be saved under the specified name.
If no anchor name is provided, the name of the anchor will be the same as the GameObject.
</summary>
<param name="gameObjectToAnchor">The GameObject to attach the anchor to.</param>
<param name="anchorName">Name of the anchor. If none provided a GUID is generated for you.</param>
<returns>The name of the newly attached anchor.</returns>
Right now, the framework overwrites my custom name and sets the gameObject name instead. The reason for this is the conditional being wrong. Instead of this:
anchorName = string.IsNullOrEmpty(anchorName) ? anchorName : gameObjectToAnchor.name;
it should be like this:
anchorName = string.IsNullOrEmpty(anchorName) ? gameObjectToAnchor.name : anchorName;
I will try to fix this myself or call for help if I can’t get it running. This means that I will go with the GameObject name, instead of the GUID and update the XML Documentation.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@eluchsinger There is no need to import anything. NUnit is already included with Unity. Just create a new class and add tags to test methods and then you can run it from the
Test Runner
window in the Unity Editor. In the Editor, you can also create a template file usingCreate > Testing > EditMode Test C# Script
.For this particular method, you’ll have to extract that logic into a separate method since it won’t run in the editor e.g.:
And then test it.
@Zod- I would still be interested in knowing if I can add Unit Tests for this case, if possible.