// Use this for initialization
    void Start()
    {
        ISN_NSBuildInfo buildInfo = ISN_NSBundle.BuildInfo;

        Debug.Log("AppVersion: " + buildInfo.AppVersion);
        Debug.Log("BuildNumber: " + buildInfo.BuildNumber);


        if (ISN_NSBundle.IsRunningInAppStoreEnvironment)
        {
            Debug.Log("This app was downloaded from an AppStore");
        }



        ISN_UIAlertController alert     = new ISN_UIAlertController("Hello", "Would you like to continue.", ISN_UIAlertControllerStyle.Alert);
        ISN_UIAlertAction     yesAction = new ISN_UIAlertAction("Yes", ISN_UIAlertActionStyle.Default, () => {
            //User said yes
        });

        //We can highlight button to show that
        //this option is preffered to be choosen
        yesAction.MakePreffered();

        ISN_UIAlertAction noAction = new ISN_UIAlertAction("No", ISN_UIAlertActionStyle.Default, () => {
            //User said no
        });

        alert.AddAction(yesAction);
        alert.AddAction(noAction);


        alert.Present();


        ISN_Preloader.LockScreen();
        ISN_Preloader.UnlockScreen();


        Debug.Log("Name:" + ISN_UIDevice.CurrentDevice.Name);
        Debug.Log("SystemName:" + ISN_UIDevice.CurrentDevice.SystemName);
        Debug.Log("SystemVersion:" + ISN_UIDevice.CurrentDevice.SystemVersion);
        Debug.Log("Model:" + ISN_UIDevice.CurrentDevice.Model);
        Debug.Log("LocalizedModel:" + ISN_UIDevice.CurrentDevice.LocalizedModel);
        Debug.Log("MajorIOSVersion:" + ISN_UIDevice.CurrentDevice.MajorIOSVersion);

        Debug.Log("UserInterfaceIdiom:" + ISN_UIDevice.CurrentDevice.UserInterfaceIdiom);
        Debug.Log("IdentifierForVendor:" + ISN_UIDevice.CurrentDevice.IdentifierForVendor);


        /*
         * ISN_UIImagePickerController.SaveScreenshotToCameraRoll((result) => {
         *  if (result.IsSucceeded) {
         *      Debug.Log("screenshot saved saved");
         *  } else {
         *      Debug.Log("Error: " + result.Error.Message);
         *  }
         * });
         *
         *
         *
         *
         *
         *
         * ISN_PHPhotoLibrary.RequestAuthorization((status) => {
         *  if(status == ISN_PHAuthorizationStatus.Authorized) {
         *      Debug.Log("Permission granted");
         *  } else {
         *      Debug.Log("Permission denied");
         *  }
         * });
         */

        ISN_PHAuthorizationStatus status;

        status = ISN_PHPhotoLibrary.AuthorizationStatus;
        Debug.Log("Photo Library Authorization Status: " + status);

        ISN_UIImagePickerController picker = new ISN_UIImagePickerController();

        picker.SourceType = ISN_UIImagePickerControllerSourceType.Camera;
        picker.MediaTypes = new List <string>()
        {
            ISN_UIMediaType.IMAGE
        };

        picker.Present((result) => {
            if (result.IsSucceeded)
            {
                Debug.Log("Image captured: " + result.Image);
            }
            else
            {
                Debug.Log("Madia picker failed with reason: " + result.Error.Message);
            }
        });

        ISN_RPScreenRecorder.StopRecording((result) => {
            if (result.IsSucceeded)
            {
                Debug.Log("Scrren recodring is started");
            }
            else
            {
                Debug.Log("User decalied screen recording request");
            }
        });

        bool isAvailable = ISN_RPScreenRecorder.IsAvailable;


        ISN_RPScreenRecorder.StopRecording((result) => {
            if (result.HasPreviewController)
            {
                result.PreviewController.Present((prevewResult) => {
                    if (prevewResult.IsSucceeded)
                    {
                        Debug.Log("User Saved video");
                        foreach (string activity in prevewResult.ActivityTypes)
                        {
                            Debug.Log("Video was shared to: " + activity);
                        }
                    }
                });
            }
        });

        ISN_RPScreenRecorder.DidChangeAvailability.AddListener(() => {
            Debug.Log("Replay Kit avalibility has chnaged:");
            Debug.Log("Replay Kit avaliable: " + ISN_RPScreenRecorder.IsAvailable);
        });


        ISN_RPScreenRecorder.DidStopRecording.AddListener((result) => {
            if (result.HasPreviewController)
            {
                result.PreviewController.Present((prevewResult) => {
                    if (prevewResult.IsSucceeded)
                    {
                        Debug.Log("User Saved video");
                        foreach (string activity in prevewResult.ActivityTypes)
                        {
                            Debug.Log("Video was shared to: " + activity);
                        }
                    }
                });
            }
        });



        /*
         *
         *
         * Texture2D myImage = GetImage();
         * ISN_UIImagePickerController.SaveTextureToCameraRoll(myImage, (result) => {
         *  if(result.IsSucceeded) {
         *      Debug.Log("Image saved");
         *  } else {
         *      Debug.Log("Error: " + result.Error.Message);
         *  }
         * });
         *
         *
         * var source = ISN_UIImagePickerControllerSourceType.PhotoLibrary;
         * bool isAvailable = ISN_UIImagePickerController.IsSourceTypeAvailable(source);
         *
         * var source = ISN_UIImagePickerControllerSourceType.Album;
         * List<string> availableMediaType = ISN_UIImagePickerController.GetAvailableMediaTypes(source);
         * foreach(var mediaType in availableMediaType) {
         *  Debug.Log(mediaType);
         * }
         */



        ISN_NSUbiquitousKeyValueStore.StoreDidChangeExternallyNotification.AddListener((changes) => {
            // get changes that might have happened while this
            // instance of your app wasn't running
        });
    }
        void OnGUI()
        {
            UpdateToStartPos();

            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Popups", style);



            StartY += YLableStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Store"))
            {
                ISN_UIAlertController alert         = new ISN_UIAlertController("My Alert", "granted", ISN_UIAlertControllerStyle.Alert);
                ISN_UIAlertAction     defaultAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                alert.AddAction(defaultAction);
                alert.Present();


                SA_Coroutine.WaitForSeconds(3f, () => {
                    alert.Dismiss();
                });
            }



            StartX  = XStartPos;
            StartY += YButtonStep;

            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #1"))
            {
                ISN_UIAlertController alert         = new ISN_UIAlertController("My Alert", "declined", ISN_UIAlertControllerStyle.Alert);
                ISN_UIAlertAction     defaultAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                ISN_UIAlertAction defaultAction2 = new ISN_UIAlertAction("No", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                defaultAction.Enabled  = true;
                defaultAction2.Enabled = false;


                ISN_UIAlertAction prefAction = new ISN_UIAlertAction("Hit me", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                    Debug.Log("Got it!!!!");
                });

                prefAction.MakePreffered();

                alert.AddAction(defaultAction);
                alert.AddAction(defaultAction2);
                alert.AddAction(prefAction);
                alert.Present();
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #2"))
            {
                ISN_Preloader.LockScreen();

                SA_Coroutine.WaitForSeconds(3f, () => {
                    ISN_Preloader.UnlockScreen();
                });
            }
        }
Пример #3
0
        void OnGUI()
        {
            UpdateToStartPos();

            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Popups", style);



            StartY += YLableStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Store"))
            {
                ISN_UIAlertController alert         = new ISN_UIAlertController("My Alert", "granted", ISN_UIAlertControllerStyle.Alert);
                ISN_UIAlertAction     defaultAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                defaultAction.SetImage(m_icon);

                alert.AddAction(defaultAction);
                alert.Present();


                SA_Coroutine.WaitForSeconds(3f, () => {
                    alert.Dismiss();
                });
            }



            StartX  = XStartPos;
            StartY += YButtonStep;

            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #1"))
            {
                ISN_UIAlertController alert         = new ISN_UIAlertController("My Alert", "declined", ISN_UIAlertControllerStyle.Alert);
                ISN_UIAlertAction     defaultAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                ISN_UIAlertAction defaultAction2 = new ISN_UIAlertAction("No", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                defaultAction.Enabled  = true;
                defaultAction2.Enabled = false;


                ISN_UIAlertAction prefAction = new ISN_UIAlertAction("Hit me", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                    Debug.Log("Got it!!!!");
                });

                prefAction.MakePreffered();

                alert.AddAction(defaultAction);
                alert.AddAction(defaultAction2);
                alert.AddAction(prefAction);
                alert.Present();
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #2"))
            {
                ISN_Preloader.LockScreen();

                SA_Coroutine.WaitForSeconds(3f, () => {
                    ISN_Preloader.UnlockScreen();
                });
            }


            StartX  = XStartPos;
            StartY += YButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Calendar Picker"))
            {
                ISN_UICalendar.PickDate((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }


            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date Time Picker"))
            {
                //20 days ago
                DateTime starDate = DateTime.Now;
                starDate = starDate.AddDays(-20);

                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();
                picker.SetDate(starDate);

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date Picker"))
            {
                //20 days ago
                DateTime starDate = DateTime.Now;
                starDate = starDate.AddDays(-20);

                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();
                picker.SetDate(starDate);
                picker.DatePickerMode = ISN_UIDateTimePickerMode.Date;

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Time Picker"))
            {
                //20 hours ago
                DateTime starDate = DateTime.Now;
                starDate = starDate.AddHours(-20);

                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();
                picker.SetDate(starDate);
                picker.DatePickerMode = ISN_UIDateTimePickerMode.Time;
                picker.MinuteInterval = 30;

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Countdown Timer"))
            {
                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();

                picker.DatePickerMode = ISN_UIDateTimePickerMode.CountdownTimer;
                picker.MinuteInterval = 10;

                //Set countdown start duration
                int      hours   = 5;
                int      minutes = 20;
                int      seconds = 0;
                TimeSpan span    = new TimeSpan(hours, minutes, seconds);
                picker.SetCountDownDuration(span);

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }
        }