示例#1
0
        private void DrawColorItem(CommandBuffer commandBuffer, int index, Vector2 margin, Vector2 padding)
        {
            var texScale   = new Vector2(_colorTexture.width, _colorTexture.height);
            var colorScale = texScale - padding * 2;

            Texture texture;

            if (index == _activeColor || (index == _highlightedColor && !_cancelHighlight))
            {
                texture = _colorTextureOn;
            }
            else
            {
                texture = _colorTexture;
            }

            int i        = index % Core.Colors.HSI_H_STEPS;
            int j        = index / Core.Colors.HSI_H_STEPS;
            var position = new Vector2 {
                x = i * (margin.x + _colorTexture.width),
                y = j * (margin.y + _colorTexture.height)
            };

            var props = new MaterialPropertyBlock();

            props.SetTexture("_MainTex", texture);
            props.SetVector("_MainTex_UV", new Vector4(1, 1, 0, 0));
            GraphicsUtility.Draw(commandBuffer, position, texScale, OpenTibiaUnity.GameManager.AppearanceTypeMaterial, props);

            position += padding;
            props     = new MaterialPropertyBlock();
            props.SetVector("_Color", Core.Colors.ColorFromHSI(index));
            GraphicsUtility.Draw(commandBuffer, position, colorScale, OpenTibiaUnity.GameManager.ColoredMaterial, props);
        }
示例#2
0
        private void DrawColorItems(CommandBuffer commandBuffer, int count, Vector2[] texPositions, Vector2[] colorPositions, Vector4[] uvs, Vector4[] colors, Vector2 padding)
        {
            var texScale   = new Vector2(_colorTexture.width, _colorTexture.height);
            var colorScale = texScale - padding * 2;

            MaterialPropertyBlock props = new MaterialPropertyBlock();

            props.SetTexture("_MainTex", _colorTexture);
            props.SetVectorArray("_MainTex_UV", uvs);
            GraphicsUtility.DrawInstanced(commandBuffer, texPositions, texScale, count, OpenTibiaUnity.GameManager.AppearanceTypeMaterial, props);

            props = new MaterialPropertyBlock();
            props.SetVectorArray("_Color", colors);
            GraphicsUtility.DrawInstanced(commandBuffer, colorPositions, colorScale, count, OpenTibiaUnity.GameManager.ColoredMaterial, props);
        }