Beispiel #1
0
        public IEnumerator AddLocation(Vector3 position)
        {
            try
            {
                if (ModConfig.Instance.Locations.Count < ModConfig.Instance.MaxLocations)
                {
                    Location location = new Location
                    {
                        Id       = position.x.ToString() + position.y.ToString() + position.z.ToString(),
                        Note     = "Type your note here",
                        Position = position
                    };
                    ModConfig.Instance.Locations.Add(location);

                    LocationPanel locationPanel = GameObject.Find("NoteItLocationPanel").GetComponent <LocationPanel>();
                    if (locationPanel != null)
                    {
                        locationPanel.ForceRefresh();
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log("[Note It!] LocationTool:AddLocation -> Exception: " + e.Message);
            }

            yield return(0);
        }
Beispiel #2
0
        public override void Start()
        {
            base.Start();

            if (_locationPanel == null)
            {
                _locationPanel = GameObject.Find("NoteItLocationPanel").GetComponent <LocationPanel>();
            }

            CreateUI();
        }
Beispiel #3
0
        public LocationItem UpdateUI()
        {
            try
            {
                _panel.width = _panel.parent.width;

                _noteTextField.width               = _panel.width - 81f;
                _noteTextField.height              = 35f;
                _noteTextField.padding             = new RectOffset(8, 8, 8, 8);
                _noteTextField.relativePosition    = new Vector3(10f, (_panel.height - _noteTextField.height) / 2);
                _noteTextField.eventTextSubmitted += (component, value) =>
                {
                    Location location = ModConfig.Instance.Locations.Find(x => x.Id == _id);
                    location.Note = value;
                };

                _focusButton.relativePosition = new Vector3(_panel.width - 66f, (_panel.height - _focusButton.height) / 2);
                _focusButton.eventClick      += (component, eventParam) =>
                {
                    if (!eventParam.used)
                    {
                        CameraController cameraController = ToolsModifierControl.cameraController;
                        cameraController.m_targetPosition = _position;
                        cameraController.ClearTarget();

                        eventParam.Use();
                    }
                };

                _deleteButton.relativePosition = new Vector3(_panel.width - 33f, (_panel.height - _deleteButton.height) / 2);
                _deleteButton.eventClick      += (component, eventParam) =>
                {
                    if (!eventParam.used)
                    {
                        ModConfig.Instance.Locations.RemoveAll(x => x.Id == _id);

                        LocationPanel locationPanel = GameObject.Find("NoteItLocationPanel").GetComponent <LocationPanel>();
                        if (locationPanel != null)
                        {
                            locationPanel.ForceRefresh();
                        }

                        eventParam.Use();
                    }
                };
            }
            catch (Exception e)
            {
                Debug.Log("[Note It!] LocationItem:UpdateUI -> Exception: " + e.Message);
            }

            return(this);
        }