Exemple #1
0
 void OnMouseUpEvent(MouseEventBase <MouseUpEvent> evt)
 {
     if (target is Button)
     {
         HandleDoubleClick();
     }
 }
 public static PAMouseEvent Create <T>(PACanvas canvas, MouseEventBase <T> evt) where T : MouseEventBase <T>, new() => new PAMouseEvent
 {
     button         = (MouseButton)evt.button,
     canvasPosition = evt.localMousePosition,
     imagePosition  = canvas.CanvasToImage(evt.localMousePosition),
     shift          = evt.shiftKey,
     alt            = evt.altKey,
     ctrl           = evt.ctrlKey
 };
Exemple #3
0
 void OnMouseDownEvent(MouseEventBase <MouseDownEvent> evt)
 {
     // Buttonの場合、MouseDownEventはButtonでは発生されないのでUpでおこなう
     if (target is Button)
     {
         return;
     }
     HandleDoubleClick();
 }
        private static MouseDownEvent MakeFromPointerEvent(IPointerEvent pointerEvent)
        {
            if (pointerEvent != null && pointerEvent.button >= 0)
            {
                PointerDeviceState.PressButton(PointerId.mousePointerId, pointerEvent.button);
            }

            return(MouseEventBase <MouseDownEvent> .GetPooled(pointerEvent));
        }
        public new static MouseUpEvent GetPooled(Event systemEvent)
        {
            if (systemEvent != null)
            {
                PointerDeviceState.ReleaseButton(PointerId.mousePointerId, systemEvent.button);
            }

            return(MouseEventBase <MouseUpEvent> .GetPooled(systemEvent));
        }
        public new static MouseLeaveWindowEvent GetPooled(Event systemEvent)
        {
            if (systemEvent != null)
            {
                PointerDeviceState.ReleaseAllButtons(PointerId.mousePointerId);
            }

            return(MouseEventBase <MouseLeaveWindowEvent> .GetPooled(systemEvent));
        }
        private static MouseUpEvent MakeFromPointerEvent(IPointerEvent pointerEvent)
        {
            // Release the equivalent mouse button
            if (pointerEvent != null && pointerEvent.button >= 0)
            {
                PointerDeviceState.ReleaseButton(PointerId.mousePointerId, pointerEvent.button);
            }

            return(MouseEventBase <MouseUpEvent> .GetPooled(pointerEvent));
        }
        public new static WheelEvent GetPooled(Event systemEvent)
        {
            WheelEvent e = MouseEventBase <WheelEvent> .GetPooled(systemEvent);

            e.imguiEvent = systemEvent;
            if (systemEvent != null)
            {
                e.delta = systemEvent.delta;
            }
            return(e);
        }
    void AddAsset(MouseEventBase <MouseUpEvent> evt)
    {
        if (assetSelectionField.value != null)
        {
            AssetType assetType = (AssetType)assetTypeSelection.value;

            foreach (VisualElement v in assetListBoxContainer.Children())
            {
                foreach (VisualElement ve in v.Children())
                {
                    if (ve.GetFirstOfType <Label>() != null)
                    {
                        if (ve.GetFirstOfType <Label>().text == assetSelectionField.value.name)
                        {
                            //Debug.LogError("An asset of similar name exists.");
                            v.Focus();
                            return;
                        }
                    }
                }
            }

            switch (assetType)
            {
            case AssetType.Texture:
                assetListBoxContainer.Add(CreateAsset(assetSelectionField.value.name));
                allGameAssets.gameTextures.Add((Texture)assetSelectionField.value);
                break;

            case AssetType.Sound:
                assetListBoxContainer.Add(CreateAsset(assetSelectionField.value.name));
                allGameAssets.gameAudioClips.Add((AudioClip)assetSelectionField.value);
                break;

            case AssetType.Font:
                assetListBoxContainer.Add(CreateAsset(assetSelectionField.value.name));
                allGameAssets.gameFonts.Add((Font)assetSelectionField.value);
                break;
                //case AssetType.CustomTileMap:
                //    assetListBoxContainer.Add(CreateAsset(assetSelectionField.value.name, true));
                //    CustomTileMap ctm = (CustomTileMap)assetSelectionField.value;
                //    //ctm.CreateTileMap();
                //    //allGameAssets.gameTileMaps.Add(ctm);
                //    EditorUtility.SetDirty(allGameAssets);
                //    ctm.Print();
                //    break;
            }

            EditorUtility.SetDirty(allGameAssets);

            //assetSelectionField.value = null;
        }
    }
Exemple #10
0
 private void OnMouseUpEvent(MouseEventBase <MouseUpEvent> evt)
 {
     switch (evt.button)
     {
     case 2:
         //中键
         if (_nodeContainer == null)
         {
             return;
         }
         _mouseMidButtonDown = false;
         break;
     }
 }
Exemple #11
0
 private void OnMouseMoveEvent(MouseEventBase <MouseMoveEvent> evt)
 {
     if (_mouseMidButtonDown)
     {
         if (_nodeContainer == null)
         {
             return;
         }
         var distance = evt.mousePosition - _mouseDragStartPos;
         _canvasPos = _canvasDragStartPos + distance;
         _nodeContainer.style.left = _canvasPos.x;
         _nodeContainer.style.top  = _canvasPos.y;
     }
 }
        public new static MouseMoveEvent GetPooled(Event systemEvent)
        {
            // For a MouseMove event type, systemEvent.button reflects
            // (at least on Windows) the currently pressed buttons,
            // whereas for mouse up/down
            // it reflects the mouse button being pressed or released
            // (there can be other buttons already pressed down).
            // These are two different semantics. We choose the second
            // one and track the button state using PointerButtonTracker.
            // We thus reset e.button for mouse move events.
            MouseMoveEvent e = MouseEventBase <MouseMoveEvent> .GetPooled(systemEvent);

            e.button = 0;
            return(e);
        }
Exemple #13
0
 private void OnMouseDownEvent(MouseEventBase <MouseDownEvent> evt)
 {
     switch (evt.button)
     {
     case 2:
         //中键
         if (_nodeContainer == null)
         {
             return;
         }
         _mouseMidButtonDown = true;
         _mouseDragStartPos  = evt.mousePosition;
         _canvasDragStartPos = _canvasPos;
         break;
     }
 }
 internal static MouseMoveEvent GetPooled(PointerMoveEvent pointerEvent)
 {
     return(MouseEventBase <MouseMoveEvent> .GetPooled(pointerEvent));
 }
Exemple #15
0
 private void OnMouseMove(MouseEventBase <MouseMoveEvent> evt)
 {
     UpdateStatesTipPos(evt.mousePosition);
 }
Exemple #16
0
 private void OnMouseLeave(MouseEventBase <MouseLeaveEvent> evt)
 {
     UpdateStatesTipPos(new Vector2(0, -100));
 }
Exemple #17
0
    //When a menu button is clicked
    void OnMenuButtonClick(MouseEventBase <MouseUpEvent> evt, Button b)
    {
        foreach (Button mb in menuButtons)
        {
            //Selected Button
            if (mb == b)
            {
                mb.RemoveFromClassList("menu-button-off");
                mb.AddToClassList("menu-button-on");

                //Add to OR Edit these conditions in case the buttons or their name change -- Had kept text of the button, but since we already have the button name information, going with name

                if (container.Contains(assetManagerContent))
                {
                    container.Remove(assetManagerContent);
                }
                if (container.Contains(objectManagerContent))
                {
                    container.Remove(objectManagerContent);
                }
                //if (container.Contains(playerEditorContent))
                //{
                //    container.Remove(playerEditorContent);
                //}
                //if (container.Contains(enemyEditorContent))
                //{
                //    container.Remove(enemyEditorContent);
                //}
                if (container.Contains(levelEditorContent))
                {
                    container.Remove(levelEditorContent);
                }

                switch (mb.name)
                {
                //Do Something here
                case "menu-button-asset":
                    container.Add(assetManagerContent);

                    break;

                case "menu-button-object":
                    container.Add(objectManagerContent);

                    break;
                //case "menu-button-player":
                //    container.Add(playerEditorContent);

                //    break;
                //case "menu-button-enemy":
                //    container.Add(enemyEditorContent);

                //    break;
                case "menu-button-level":
                    container.Add(levelEditorContent);

                    break;

                default:
                    Debug.LogError("Change the name of the button OR change the switch case here.");
                    break;
                }
            }
            else
            {
                mb.RemoveFromClassList("menu-button-on");
                mb.AddToClassList("menu-button-off");
            }
        }
    }
Exemple #18
0
 void OnMouseDownEvent(MouseEventBase <MouseDownEvent> evt)
 {
     Debug.Log("Receiving " + evt + " in " + evt.propagationPhase + " for target " + evt.target);
 }
Exemple #19
0
 void OnMouseOutEvent(MouseEventBase <MouseOutEvent> evt)
 {
     isClicked = false;
 }
Exemple #20
0
 void OnMouseDownEvent(MouseEventBase <MouseDownEvent> evt)
 {
     Slab.style.backgroundColor = SecondaryColor;
 }
Exemple #21
0
 void OnMouseLeaveEvent(MouseEventBase <MouseLeaveEvent> evt)
 {
     Slab.style.backgroundColor = OriginalColor;
 }
 void Repaint <T>(MouseEventBase <T> evt) where T : MouseEventBase <T>, new()
 {
     evt.StopPropagation();
     this.MarkDirtyRepaint();
 }
    void SaveAssets(MouseEventBase <MouseUpEvent> evt)
    {
        //Create Destination folder

        if (AssetDatabase.IsValidFolder("Assets/Export"))
        {
            //Debug.Log("Exists");
        }
        else
        {
            string ret;

            ret = AssetDatabase.CreateFolder("Assets", "Export");
            if (AssetDatabase.GUIDToAssetPath(ret) != "")
            {
                Debug.Log("Folder asset created");
            }
            else
            {
                Debug.Log("Couldn't find the GUID for the path");
            }
        }
        AssetDatabase.Refresh();
        if (AssetDatabase.IsValidFolder("Assets/Export/Assets"))
        {
            //Debug.Log("Exists");
        }
        else
        {
            string ret;

            ret = AssetDatabase.CreateFolder("Assets/Export", "Assets");
            if (AssetDatabase.GUIDToAssetPath(ret) != "")
            {
                Debug.Log("Folder asset created");
            }
            else
            {
                Debug.Log("Couldn't find the GUID for the path");
            }
        }
        AssetDatabase.Refresh();

        //Create Texture Assets

        if (AssetDatabase.IsValidFolder("Assets/Export/Assets/Images"))
        {
            //Debug.Log("Exists");
        }
        else
        {
            string ret;

            ret = AssetDatabase.CreateFolder("Assets/Export/Assets", "Images");
            if (AssetDatabase.GUIDToAssetPath(ret) != "")
            {
                Debug.Log("Folder asset created");
            }
            else
            {
                Debug.Log("Couldn't find the GUID for the path");
            }
        }
        foreach (Texture t in allGameAssets.gameTextures)
        {
            if (AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(t), "Assets/Export/Assets/Images/" + t.name + ".png"))
            {
                //Debug.Log("Material asset copied as Assets/Export/Images/" + t.name + ".png");
                AssetInfo a = new AssetInfo();
                a.Class = "TextureAsset";
                a.guid  = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(t));
                a.path  = "..Assets/Export/Images/" + t.name + ".png";



                string str = JsonUtility.ToJson(a);
                using (FileStream fs = new FileStream("Assets/Export/Assets/Images/" + t.name + ".png.json", FileMode.Create))
                {
                    using (StreamWriter writer = new StreamWriter(fs))
                    {
                        writer.Write(str);
                        writer.Close();
                        writer.Dispose();
                    }
                    fs.Close();
                    fs.Dispose();
                }
            }
            else
            {
                //Debug.Log("Couldn't copy the image");
            }
            // Manually refresh the Database to inform of a change
            AssetDatabase.Refresh();
        }

        //Create Audio Clip Assets

        if (AssetDatabase.IsValidFolder("Assets/Export/Assets/Audio"))
        {
            //Debug.Log("Exists");
        }
        else
        {
            string ret;

            ret = AssetDatabase.CreateFolder("Assets/Export/Assets", "Audio");
            if (AssetDatabase.GUIDToAssetPath(ret) != "")
            {
                Debug.Log("Folder asset created");
            }
            else
            {
                Debug.Log("Couldn't find the GUID for the path");
            }
        }
        foreach (AudioClip ac in allGameAssets.gameAudioClips)
        {
            if (AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(ac), "Assets/Export/Assets/Audio/" + ac.name + ".mp3"))
            {
                //Debug.Log("Material asset copied as Assets/Export/Audio/" + ac.name + ".mp3");
                AssetInfo a = new AssetInfo();
                a.Class = "AudioAsset";
                a.guid  = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(ac));
                a.path  = "..Assets/Export/Audio/" + ac.name + ".mp3";



                string str = JsonUtility.ToJson(a);
                using (FileStream fs = new FileStream("Assets/Export/Assets/Audio/" + ac.name + ".mp3.json", FileMode.Create))
                {
                    using (StreamWriter writer = new StreamWriter(fs))
                    {
                        writer.Write(str);
                        writer.Close();
                        writer.Dispose();
                    }
                    fs.Close();
                    fs.Dispose();
                }
            }
            else
            {
                //Debug.Log("Couldn't copy the audio clip");
            }
            // Manually refresh the Database to inform of a change
            AssetDatabase.Refresh();
        }

        //Create Font Assets

        if (AssetDatabase.IsValidFolder("Assets/Export/Assets/Fonts"))
        {
            //Debug.Log("Exists");
        }
        else
        {
            string ret;

            ret = AssetDatabase.CreateFolder("Assets/Export/Assets", "Fonts");
            if (AssetDatabase.GUIDToAssetPath(ret) != "")
            {
                Debug.Log("Folder asset created");
            }
            else
            {
                Debug.Log("Couldn't find the GUID for the path");
            }
        }
        foreach (Font f in allGameAssets.gameFonts)
        {
            if (AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(f), "Assets/Export/Assets/Fonts/" + f.name + ".ttf"))
            {
                //Debug.Log("Material asset copied as Assets/Export/Fonts/" + f.name + ".ttf");
                AssetInfo a = new AssetInfo();
                a.Class = "FontAsset";
                a.guid  = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(f));
                a.path  = "..Assets/Export/Fonts/" + f.name + ".ttf";



                string str = JsonUtility.ToJson(a);
                using (FileStream fs = new FileStream("Assets/Export/Assets/Fonts/" + f.name + ".ttf.json", FileMode.Create))
                {
                    using (StreamWriter writer = new StreamWriter(fs))
                    {
                        writer.Write(str);
                        writer.Close();
                        writer.Dispose();
                    }
                    fs.Close();
                    fs.Dispose();
                }
            }
            else
            {
                //Debug.Log("Couldn't copy the font");
            }
            // Manually refresh the Database to inform of a change
            AssetDatabase.Refresh();
        }
    }
Exemple #24
0
 private void OnMouseEnter(MouseEventBase <MouseEnterEvent> evt)
 {
     SetStatesTip();
     UpdateStatesTipPos(evt.mousePosition);
 }
 void OnMouseDownEvent(MouseEventBase <MouseDownEvent> evt)
 {
     target.style.backgroundColor = new StyleColor(Color.red);
 }
 void OnMouseUpEvent(MouseEventBase <MouseUpEvent> evt)
 {
     target.style.backgroundColor = OriginalColor;
 }
 void Repaint <T>(MouseEventBase <T> evt) where T : MouseEventBase <T>, new()
 {
     evt.StopPropagation();
     Dirty(ChangeType.Repaint);
 }
Exemple #28
0
 void OnMouseUpEvent(MouseEventBase <MouseUpEvent> evt)
 {
     Debug.Log("Mouse Up " + evt + " in " + evt.propagationPhase + " for target " + evt.target);
 }