Example #1
0
        internal static Anchor Factory(NativeSession nativeApi, IntPtr anchorNativeHandle,
                                       bool isCreate = true)
        {
            if (anchorNativeHandle == IntPtr.Zero)
            {
                return(null);
            }

            Anchor result;

            if (s_AnchorDict.TryGetValue(anchorNativeHandle, out result))
            {
                // Release acquired handle and return cached result
                AnchorApi.Release(anchorNativeHandle);
                return(result);
            }

            if (isCreate)
            {
                Anchor anchor = (new GameObject()).AddComponent <Anchor>();
                anchor.gameObject.name = "Anchor";
                anchor.NativeHandle    = anchorNativeHandle;
                anchor.NativeSession   = nativeApi;
                anchor.Update();

                s_AnchorDict.Add(anchorNativeHandle, anchor);
                return(anchor);
            }

            return(null);
        }
Example #2
0
        public static Anchor AnchorFactory(IntPtr anchorNativeHandle, NativeApi nativeApi)
        {
            if (anchorNativeHandle == IntPtr.Zero)
            {
                return(null);
            }

            Anchor result;

            if (s_AnchorDict.TryGetValue(anchorNativeHandle, out result))
            {
                // Release acquired handle and return cached result
                result.m_NativeApi.Anchor.Release(anchorNativeHandle);
                return(result);
            }

            Anchor anchor = (new GameObject()).AddComponent <Anchor>();

            anchor.gameObject.name      = "Anchor";
            anchor.m_AnchorNativeHandle = anchorNativeHandle;
            anchor.m_NativeApi          = nativeApi;
            anchor.Update();

            s_AnchorDict.Add(anchorNativeHandle, anchor);
            return(anchor);
        }