Пример #1
0
        public Material Create(AssetDatabase ad, RenderContext rc, Dictionary <string, ConstantBufferDataProvider> providers = null)
        {
            Material ret;

            if (!CreatedResourceCache.TryGetCachedItem(this, out ret))
            {
                MaterialTextureInputElement[] texElements = TextureInputs.Select(ta => ta.Create(ad)).ToArray();
                var allTextures           = texElements.Concat(ContextTextures).ToArray();
                var materialTextureInputs = new MaterialTextureInputs(allTextures);
                MaterialInputs <MaterialGlobalInputElement> globalInputs;
                if (providers != null)
                {
                    globalInputs =
                        new MaterialInputs <MaterialGlobalInputElement>(GlobalInputs.Select(mgid => mgid.Create(providers)).ToArray());
                }
                else
                {
                    globalInputs =
                        new MaterialInputs <MaterialGlobalInputElement>(GlobalInputs.Select(mgid => mgid.Create()).ToArray());
                }
                MaterialInputs <MaterialPerObjectInputElement> perObjectInputs = new MaterialInputs <MaterialPerObjectInputElement>(PerObjectInputs);
                ret = rc.ResourceFactory.CreateMaterial(rc, VertexShader, FragmentShader, VertexInputs, globalInputs, perObjectInputs, materialTextureInputs);

                CreatedResourceCache.CacheItem(this, ret);
            }

            return(ret);
        }
    public static float GetZoomOut()
    {
                #if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_EDITOR
        if (Input.GetKey(KeyCode.PageDown) || Input.GetKey(KeyCode.Minus) || Input.GetKey(KeyCode.KeypadMinus))
        {
            return(1f);
        }
        else if (Input.GetAxisRaw("Mouse ScrollWheel") < 0)
        {
            return(8f);
        }
                #else
        if (GlobalInputs.GetPinchIn())
        {
            return(1f);
        }
                #endif

        return(0);
    }
    public static bool Rotate()
    {
                #if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            return(true);
        }


        /*	Mobile inputs.
         *	Returns true if the taps the screen.
         */
        #else
        if (GlobalInputs.GetRotate())
        {
            return(true);
        }
        #endif

        return(false);
    }
    public static bool GetCameraRight(bool isDraging = false)
    {
                #if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_EDITOR
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
        {
            return(true);
        }
        else if (isDraging && Input.mousePosition.x > Camera.main.pixelWidth * 0.98f)
        {
            return(true);
        }
                #else
        if (GlobalInputs.GetSwipe(Vector2.left, true))
        {
            return(true);
        }
        else if (Input.touchCount == 1 && isDraging && Input.GetTouch(0).position.x > Camera.main.pixelWidth * 0.98f)
        {
            return(true);
        }
                #endif

        return(false);
    }
    public static bool GetCameraDown(bool isDraging = false)
    {
                #if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_EDITOR
        if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
        {
            return(true);
        }
        else if (isDraging && Input.mousePosition.y < Camera.main.pixelHeight * 0.02f)
        {
            return(true);
        }
                #else
        if (GlobalInputs.GetSwipe(Vector2.up, true))
        {
            return(true);
        }
        else if (Input.touchCount == 1 && isDraging && Input.GetTouch(0).position.y < Camera.main.pixelHeight * 0.02f)
        {
            return(true);
        }
                #endif

        return(false);
    }
Пример #6
0
    private void Update()
    {
        if (!isLocked)
        {
            if (GameManager.Instance.currentState == GameManager.GameState.LevelEditor)
            {
                //If cursor isn't over UI;
                bool tPointerOverUI;

#if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_EDITOR
                tPointerOverUI = EventSystem.current.IsPointerOverGameObject();
                if (Input.GetMouseButtonDown(0))
                {
                    //Check if touch an object no matter where you press on it;
                    Ray            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit2D[] hit = Physics2D.GetRayIntersectionAll(ray, 10f);
                    foreach (RaycastHit2D o in hit)
                    {
                        transObj = o.transform;
                        break;
                    }
                }
#else
                tPointerOverUI = IsPointerOverUIObject();
#endif
                if (!tPointerOverUI)
                {
                    int[]   objColRow = new int[2];   //0 = column, 1 = row
                    float[] objPos    = new float[2]; //0 = x, 1 = y
                    if (transObj != null)
                    {
                        GetObjPosition(ref objColRow, ref objPos, transObj.position);
                        transObj = null;
                    }
                    else
                    {
                        Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                        GetObjPosition(ref objColRow, ref objPos, mousePosition);
                    }

                    if (LevelEditorInputs.GetBrush())
                    {
                        if (eraser)
                        {
                            AddDeleteTile(objColRow, objPos, false);
                        }
                        else if (!cursor)
                        {
                            if (glitchUI.isActive)
                            {
                                glitchUI.AddTeleport(objPos);
                            }
                            else if (objPos[0] > 0 && objPos[0] < LevelManager.Instance.mapSize.x && objPos[1] > 0 && objPos[1] < LevelManager.Instance.mapSize.y)
                            {
                                AddDeleteTile(objColRow, objPos, true);
                            }
                        }
                    }
                    else if (LevelEditorInputs.GetEraser())
                    {
                        AddDeleteTile(objColRow, objPos, false);
                    }
                }
                GlobalInputs.ClearInputs();
            }
        }
    }