예제 #1
0
        public WorldAnchor Load(string id, GameObject go)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException("id must not be null or empty", "id");
            }
            if (go == null)
            {
                throw new ArgumentNullException("anchor");
            }
            WorldAnchor worldAnchor = go.GetComponent <WorldAnchor>();
            bool        flag        = worldAnchor != null;

            if (worldAnchor == null)
            {
                worldAnchor = go.AddComponent <WorldAnchor>();
            }
            WorldAnchor result;

            if (WorldAnchorStore.Load_Internal(this.m_NativePtr, id, worldAnchor))
            {
                result = go.GetComponent <WorldAnchor>();
            }
            else
            {
                if (!flag)
                {
                    UnityEngine.Object.DestroyImmediate(worldAnchor);
                }
                result = null;
            }
            return(result);
        }