// Request permissions from the user (if not already granted to provide permissions for highlight capture)
        public static void RequestPermissions(EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot request permissions. The SDK has not been initialized.");
                return;
            }

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(cid, asyncOp, false);
                Highlights_RequestPermissionsAsync(asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(asyncOp);
            }
        }
        // Closes out a group and purges the unsaved contents.
        public static void CloseGroup(CloseGroupParams closeGroupParams, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot close a group. The SDK has not been initialized.");
                return;
            }

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(closeGroupParams));

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(closeGroupParams, pnt, false);
                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_CloseGroupAsync(pnt, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(pnt);
                Marshal.FreeHGlobal(asyncOp);
            }
        }
        // Opens up Summary Dialog for one or more groups
        public static void OpenSummary(GroupView[] summaryParams, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot open summary. The SDK has not been initialized.");
                return;
            }

            List <IntPtr> allocatedMemory = new List <IntPtr>();
            IntPtr        nativeArray     = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * summaryParams.Length);

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                for (int i = 0; i < summaryParams.Length; ++i)
                {
                    GroupViewInternal gvi = new GroupViewInternal();
                    gvi.groupId            = summaryParams[i].GroupId;
                    gvi.significanceFilter = (int)(summaryParams[i]).SignificanceFilter;
                    gvi.tagFilter          = (int)(summaryParams[i]).TagFilter;

                    IntPtr nativeSummaryParams = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(GroupViewInternal)));
                    allocatedMemory.Add(nativeSummaryParams);
                    Marshal.StructureToPtr(gvi, nativeSummaryParams, false);
                    Marshal.WriteIntPtr(nativeArray, Marshal.SizeOf(typeof(IntPtr)) * i, nativeSummaryParams);
                }

                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_OpenSummaryAsync(summaryParams.Length, nativeArray, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(nativeArray);
                Marshal.FreeHGlobal(asyncOp);

                foreach (IntPtr ptr in allocatedMemory)
                {
                    Marshal.FreeHGlobal(ptr);
                }
            }
        }
        // Begins a "group" which groups several Highlights together.
        public static void OpenGroup(OpenGroupParams openGroupParams, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot open a group. The SDK has not been initialized.");
                return;
            }

            OpenGroupParamsInternal ogp = new OpenGroupParamsInternal();

            ogp.id = openGroupParams.Id;

            StringBuilder sb = new StringBuilder();

            foreach (TranslationEntry te in openGroupParams.GroupDescriptionTable)
            {
                sb.Append(te.Language).Append("\a").Append(te.Translation).Append("\a");
            }

            ogp.groupDescriptionTable = sb.ToString();

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(ogp));

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(ogp, pnt, false);
                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_OpenGroupAsync(pnt, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(pnt);
                Marshal.FreeHGlobal(asyncOp);
            }
        }
        // Configure Highlights. Takes an array of highlight definition objects to define highlights in the game
        public static void ConfigureHighlights(HighlightDefinition[] highlightDefinitions, string defaultLocale, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot configure Highlights. The SDK has not been initialized.");
                return;
            }

            SetDefaultLocale(defaultLocale);

            var allocatedMemory = new List <IntPtr>();

            IntPtr nativeArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * highlightDefinitions.Length);

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                for (int i = 0; i < highlightDefinitions.Length; ++i)
                {
                    IntPtr nativeHighlightsDefinition = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HighlightDefinitionInternal)));
                    HighlightDefinitionInternal hd    = new HighlightDefinitionInternal();
                    hd.id                  = highlightDefinitions[i].Id;
                    hd.highlightTags       = (int)(highlightDefinitions[i]).HighlightTags;
                    hd.significance        = (int)(highlightDefinitions[i]).Significance;
                    hd.userDefaultInterest = (highlightDefinitions[i]).UserDefaultInterest;
                    StringBuilder sb = new StringBuilder();
                    foreach (TranslationEntry te in (highlightDefinitions[i]).NameTranslationTable)
                    {
                        sb.Append(te.Language).Append("\a").Append(te.Translation).Append("\a");
                    }
                    hd.languageTranslationStrings = sb.ToString();
                    allocatedMemory.Add(nativeHighlightsDefinition);
                    Marshal.StructureToPtr(hd, nativeHighlightsDefinition, false);
                    Marshal.WriteIntPtr(nativeArray, i * Marshal.SizeOf(typeof(IntPtr)), nativeHighlightsDefinition);
                }

                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_ConfigureAsync(highlightDefinitions.Length, nativeArray, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(nativeArray);
                Marshal.FreeHGlobal(asyncOp);

                foreach (IntPtr ptr in allocatedMemory)
                {
                    Marshal.FreeHGlobal(ptr);
                }
            }
        }
示例#6
0
        // Records a video highlight for the given group. Attached metadata to it to make the Highlight more interesting.
        // Set the start and end delta to change the length of the video clip.
        public static void SetVideoHighlight(VideoHighlightParams videoHighlightParams, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Console.WriteLine("ERROR: Cannot record a video. The SDK has not been initialized.");
                return;
            }

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(videoHighlightParams));

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(videoHighlightParams, pnt, false);
                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_SetVideoHighlightAsync(pnt, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(pnt);
                Marshal.FreeHGlobal(asyncOp);
            }
        }