Exemple #1
0
    public void Awake()
    {
        List <Image> childs = this.GetComponentsInChildren <Image>().ToList();

        foreach (var child in childs)
        {
            if (child.gameObject != this.gameObject)
            {
                MeshImage mi = null;
                if (child.gameObject.GetComponent <MeshImage>() != null)
                {
                    mi      = child.gameObject.GetComponent <MeshImage>();
                    mi.mask = this;
                }

                MeshRawImage mri = null;
                if (child.gameObject.GetComponent <MeshRawImage>() != null)
                {
                    mri      = child.gameObject.GetComponent <MeshRawImage>();
                    mri.mask = this;
                }

                MeshButton mb = null;
                if (child.gameObject.GetComponent <MeshButton>() != null)
                {
                    mb      = child.gameObject.GetComponent <MeshButton>();
                    mb.mask = this;
                }
            }
        }
    }
    public override void ModifyMesh(VertexHelper vh)
    {
        if (this.enabled)
        {
            vertices = polygon2d.GetPath(0).ToList();
            //vh.Clear();
            //if (vertices != null && triangles != null)
            //{
            //    float tw = image.rectTransform.rect.width;
            //    float th = image.rectTransform.rect.height;
            //    Vector4 uv = image.overrideSprite != null ? DataUtility.GetOuterUV(image.overrideSprite) : Vector4.zero;
            //    float uvCenterX = (uv.x + uv.z) * 0.5f;
            //    float uvCenterY = (uv.y + uv.w) * 0.5f;
            //    float uvScaleX = (uv.z - uv.x) / tw;
            //    float uvScaleY = (uv.w - uv.y) / th;

            //    for (int i = 0; i < vertices.Count; i++)
            //    {
            //        UIVertex v = new UIVertex();
            //        v.color = image.color;
            //        //v.position = new Vector2(vertices[i].x * tw, vertices[i].y * tw);
            //        v.position = vertices[i];
            //        v.uv0 = new Vector2(v.position.x * uvScaleX + uvCenterX, v.position.y * uvScaleY + uvCenterY);
            //        _uiVertices.Add(v);
            //    }

            //    vh.AddUIVertexStream(_uiVertices, triangles);
            //}

            List <Image> childs = this.GetComponentsInChildren <Image>().ToList();
            foreach (var child in childs)
            {
                if (child.gameObject != this.gameObject)
                {
                    MeshImage mi = null;
                    if (child.gameObject.GetComponent <MeshImage>() != null)
                    {
                        mi      = child.gameObject.GetComponent <MeshImage>();
                        mi.mask = this;
                    }

                    MeshButton mb = null;
                    if (child.gameObject.GetComponent <MeshButton>() != null)
                    {
                        mb      = child.gameObject.GetComponent <MeshButton>();
                        mb.mask = this;
                    }
                }
            }
        }
    }
    private void OnButtonClicked(MeshButton clickedButton)
    {
        GameMode newMode;

        if (clickedButton.IsSelected)
        {
            newMode = GameMode.None;
            clickedButton.SetSelected(false);
        }
        else
        {
            switch (clickedButton.ButtonName)
            {
            case "target":
                newMode = GameMode.Target;
                break;

            case "destroy":
                newMode = GameMode.Delete;
                break;

            default:
                newMode = GameMode.Spawn;
                break;
            }

            foreach (MeshButton button in buttons)
            {
                button.SetSelected(button == clickedButton);
            }
        }

        GameModeMessage message = new GameModeMessage();

        message.Mode = newMode;
        Message.Send <GameModeMessage>(message);
    }
    private void OnButtonClicked(MeshButton clickedButton)
    {
        if (isLoading)
        {
            return;
        }

        logo.SetActive(false);

        switch (clickedButton.ButtonName)
        {
        case "new":
            NewGame();
            break;

        case "load":
            LoadGame();
            break;

        case "save":
            SaveGame();
            break;
        }
    }
 private void OnLogoClicked(MeshButton clickedButton)
 {
     OpenWebsite();
 }
Exemple #6
0
    public void OnUpdate()
    {
        if (cam == null)
        {
            return;
        }

        if (Application.isEditor)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit rayHit;
                if (Physics.Raycast(ray, out rayHit, 2000, ~(1 << 12)))
                {
                    GameObject obj = rayHit.collider.gameObject;
                    if (obj.CompareTag("meshButton") | obj.CompareTag("meshButton_Begin"))
                    {
                        MeshButton button = obj.GetComponent <MeshButton>();
                        if (button != null)
                        {
                            button.MeshHit();
                            button.MeshHit(obj);
                        }
                    }
                }
            }
        }
        if (Input.touchCount >= 1)
        {
            Ray        ray = cam.ScreenPointToRay(Input.GetTouch(0).position);
            RaycastHit rayHit;
            Touch      touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                if (Physics.Raycast(ray, out rayHit))
                {
                    if (Physics.Raycast(ray, out rayHit, 2000, ~(1 << 12)))
                    {
                        GameObject obj = rayHit.collider.gameObject;
                        if (obj.CompareTag("meshButton_Begin"))
                        {
                            MeshButton button = obj.GetComponent <MeshButton>();
                            if (button != null)
                            {
                                button.MeshHit();
                                button.MeshHit(obj);
                            }
                        }
                    }
                }
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                if (Physics.Raycast(ray, out rayHit, 2000, ~(1 << 12)))
                {
                    GameObject obj = rayHit.collider.gameObject;
                    if (obj.CompareTag("meshButton"))
                    {
                        MeshButton button = obj.GetComponent <MeshButton>();
                        if (button != null)
                        {
                            button.MeshHit();
                            button.MeshHit(obj);
                        }
                    }
                }
            }
        }
    }
Exemple #7
0
 public void SetMeshButtonInteractable(MeshButton button, bool flag)
 {
     button.Interactable = flag;
 }