コード例 #1
0
        //Paste the copied objects by instantiating them
        private void PasteSelection()
        {
            //Temporary GameObject to enable cloned objects before storing them
            GameObject objectClone;

            //Reset the current selection
            ObjectSelection.Instance.DeselectAll();

            //Loop through all of the copied objects
            foreach (Transform copiedObject in Instance.copiedObjectsRoot.transform)
            {
                //Instantiate and enable the cloned object
                objectClone = Instantiate(copiedObject.gameObject);
                objectClone.SetActive(true);
                //Get a reference to the cloned object's MapObject script
                MapObject mapObjectScript = objectClone.GetComponent <MapObject>();
                //Copy the values of the original map object script
                mapObjectScript.CopyValues(copiedObject.GetComponent <MapObject>());
                //Add the object to the map and make it selectable
                AddObjectToMap(objectClone, mapObjectScript);
                ObjectSelection.Instance.SelectObject(objectClone);
            }

            //Once the selection is pasted, change the tool type to translate
            ToolButtonManager.SetTool(Tool.Translate);

            //Notify listeners that the copied objects were pasted at the end of the frame
            StartCoroutine(InvokeOnPaste());
        }
コード例 #2
0
 //Change the image and state to selected
 private void select()
 {
     //Set the button images
     imageScript.sprite = selected;
     currentState       = ButtonState.Selected;
     SelectedButton     = this;
     //Execute the action of the button
     action();
 }
コード例 #3
0
        //If the mouse is pressed down on the button and its not selected, change to the pressed image
        public void OnPointerDown(PointerEventData data)
        {
            MouseDown = true;

            if (currentState == ButtonState.Unselected)
            {
                imageScript.sprite = pressed;
                currentState       = ButtonState.Pressed;
                PressedButton      = this;
            }
        }