コード例 #1
0
        /// <summary>
        /// Awake plugin
        /// </summary>
        void Awake()
        {
            Logger.LogInfo("In Awake for ImageToPlane");

            Debug.Log("ImageToPlane Plug-in loaded");
            LoadImage     = Config.Bind("Hotkeys", "Load Image Shortcut", new KeyboardShortcut(KeyCode.F1));
            ClearImage    = Config.Bind("Hotkeys", "Clear Image Shortcut", new KeyboardShortcut(KeyCode.F2));
            PixelsPerTile = Config.Bind("Scale", "Scale Size", 40);

            // Load PUP
            ModdingTales.ModdingUtils.Initialize(this, Logger);
            PhotonUtilPlugin.AddMod(Guid);
        }
コード例 #2
0
        /// <summary>
        /// Looping method run by plugin
        /// </summary>
        void Update()
        {
            if (OnBoard())
            {
                try
                {
                    if (Input.GetKey(LoadImage.Value.MainKey))
                    {
                        SystemMessage.AskForTextInput("Board URL", "Enter the URL to your map (PNG or JPG Image Only)", "OK", delegate(string mediaUrl)
                        {
                            if (mediaUrl.Length > 256)
                            {
                            }
                            else
                            {
                                PhotonUtilPlugin.AddMessage(new PhotonMessage
                                {
                                    PackageId         = Guid,
                                    SerializedMessage = mediaUrl,
                                    Version           = Version,
                                });
                            }
                        }, delegate
                        {
                        }, "Open Board Locally Instead", delegate
                        {
                            var dialog = new OpenFileDialog
                            {
                                Filter           = "Image Files|*.bmp;*.jpg;*.jpeg;*.png;",
                                InitialDirectory = "C:",
                                Title            = "Select an Image"
                            };
                            string path = null;
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                path = dialog.FileName;
                            }
                            if (string.IsNullOrWhiteSpace(path))
                            {
                                return;
                            }

                            // make map
                            var fileContent = File.ReadAllBytes(path);
                            MakeMap(fileContent);
                        });
                    }
                    else if (Input.GetKey(ClearImage.Value.MainKey) && _rendered)
                    {
                        Cleanup();
                        ClearMessage();
                        var message = new PhotonMessage
                        {
                            PackageId         = Guid,
                            Version           = Version,
                            SerializedMessage = "Clear"
                        };
                        PhotonUtilPlugin.AddMessage(message);
                    }
                    else if (DateTime.Now - _lastChecked > _fetchTimeSpan)
                    {
                        _lastChecked = DateTime.Now;
                        var messages = PhotonUtilPlugin.GetNewMessages(Guid);
                        foreach (var message in from m in messages.Values from message in m where message != null && !message.Viewed select message)
                        {
                            StartCoroutine(DownloadImage(message.SerializedMessage));
                        }
                    }
                    else if (load)
                    {
                        MakeMap(BufferTexture);
                        load = false;
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log("Crash in Image To Plane Plugin");
                    Debug.Log(ex.Message);
                    Debug.Log(ex.StackTrace);
                    Debug.Log(ex.InnerException);
                    Debug.Log(ex.Source);
                }
            }
        }
コード例 #3
0
 private static void ClearMessage()
 {
     PhotonUtilPlugin.ClearNonPersistent(Guid);
 }