Exemplo n.º 1
0
    public void OnEnable()
    {
        m_sr  = GetComponent <SpriteRenderer>();
        m_tex = m_sr?.sprite.texture;
        float max = Mathf.Max(m_tex.width, m_tex.height);
        float pow = Mathf.Ceil(max / 64.0f);

        if (pow == 1)
        {
            TexSize    = TextureMode.TEX64;
            Dimensions = 64;
        }
        if (pow == 2)
        {
            TexSize    = TextureMode.TEX128;
            Dimensions = 128;
        }
        if (pow == 3 || pow == 4)
        {
            TexSize    = TextureMode.TEX256;
            Dimensions = 256;
        }
        if (pow >= 5 && pow <= 8)
        {
            TexSize    = TextureMode.TEX512;
            Dimensions = 512;
        }


        Rebuild = true;
        RayCastMaster.SubscribeTexture(this);
        m_sr = GetComponent <SpriteRenderer>();
    }
        public TextureMaterial(Bitmap texture, TextureMode mode)
        {
            _mode   = mode;
            _width  = texture.Width;
            _height = texture.Height;

            _data = new Vector3[_width, _height];

            var data = texture.LockBits(new Rectangle(0, 0, _width, _height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);

            unsafe
            {
                byte *p = (byte *)data.Scan0;
                for (int y = 0; y < _height; y++)
                {
                    var i = 0;
                    for (int x = 0; x < _width * 3; x += 3, i++)
                    {
                        var r = *(p++);
                        var g = *(p++);
                        var b = *(p++);

                        _data[i, y] = new Vector3(r / 255f, g / 255f, b / 255f);
                    }
                }

                texture.UnlockBits(data);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Construct the renderer.
        /// </summary>
        /// <param name="texmode">
        /// A <see cref="TextureMode"/>. Choose "TextureMode.NORMAL_MODE" if your graphics card supports non-power of 2 texture sizes, TextureMode.TEXTURE_RECTANGLE_EXT otherwise.
        /// </param>
        public Renderer(TextureMode texmode, Display display, ResourceManager resourceManager)
        {
            this.resourceManager = resourceManager;
            textureMode = texmode;

            try
            {
                CheckRendererStatus();
            }
            catch (Exception e)
            {
                Log.Write("Could not initialize renderer: " + e.Message);
                throw e;
            }

            //Set some OpenGL attributes
            Gl.glDisable(Gl.GL_DEPTH_TEST);
            Gl.glEnable(GlTextureMode);
            Gl.glShadeModel(Gl.GL_SMOOTH);
            Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);

            //Enable alpha blending
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
            Gl.glEnable(Gl.GL_BLEND);

            Ready = true;

            Gl.glColor4d(1, 1, 1, 1);
            /*Gl.glDrawBuffer(Gl.GL_BACK);
            Gl.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);
            Gl.glClear(Gl.GL_ACCUM_BUFFER_BIT);*/
        }
Exemplo n.º 4
0
    public Texture2D GetTextureForChunk(int chunkX, int chunkY, TextureMode mode)
    {
        switch (mode)
        {
        case TextureMode.None:
            break;

        case TextureMode.Default:
            Texture2D tex = new Texture2D(Chunk.WIDTH * TILE_RESOLUTION, Chunk.HEIGHT * TILE_RESOLUTION);
            tex.filterMode = FilterMode.Point;

            for (int x = 0; x < tex.width; x++)
            {
                for (int y = 0; y < tex.height; y++)
                {
                    tex.SetPixel(x, y, Color.green);
                }
            }

            tex.Apply();
            return(tex);

        case TextureMode.Active:
            List <ChunkTile> drawQueue = ManagerInstance.Get <WorldManager>().GetChunkAt(chunkX, chunkY).tileDrawQueue;
            Texture2D        activeTex = ManagerInstance.Get <WorldManager>().GetChunkObjectAt(chunkX, chunkY).texture;

            if (activeTex == null)
            {
                activeTex = new Texture2D(Chunk.WIDTH * TILE_RESOLUTION, Chunk.HEIGHT * TILE_RESOLUTION);
            }
            activeTex.filterMode = FilterMode.Point;

            for (int i = 0; i < drawQueue.Count; i++)
            {
                activeTex.SetPixels(drawQueue[i].x * TILE_RESOLUTION, drawQueue[i].y * TILE_RESOLUTION, TILE_RESOLUTION, TILE_RESOLUTION, TileTexture(drawQueue[i].worldX, drawQueue[i].worldY));
                if (drawQueue[i].identity != "default")
                {
                    if (playMode)
                    {
                        ManagerInstance.Get <WorldManager>().GetChunkObjectAt(chunkX, chunkY).EmiteParticles(drawQueue[i].x, drawQueue[i].y, TileSelectionPanel.i.selectedTile.graphics.particleColor);
                    }
                }
            }

            drawQueue.Clear();
            activeTex.Apply();
            return(activeTex);

        case TextureMode.Serialized:
            break;

        default:
            break;
        }

        return(null);
    }
Exemplo n.º 5
0
    public void SetGraphics(TextureMode mode)
    {
        GetComponent <Renderer>().sharedMaterial = new Material(Resources.Load("Materials/chunk") as Material);
        Texture2D oldTex = GetComponent <Renderer>().sharedMaterial.mainTexture as Texture2D;

        GetComponent <Renderer>().sharedMaterial.mainTexture = oldTex;
        GetComponent <Renderer>().sharedMaterial.mainTexture = ManagerInstance.Get <WorldGraphicsManager>().GetTextureForChunk(m_chunk.x, m_chunk.y, mode);
        m_chunk.AddChunkToDrawQueue();
    }
Exemplo n.º 6
0
 /// <summary>
 /// Pastes the specified style.
 /// </summary>
 /// <param name="style">The style.</param>
 public void Paste(Style style)
 {
     Font        = style.Font;
     Tint        = style.Tint;
     Opacity     = style.Opacity;
     BackColor   = style.BackColor;
     TextColor   = style.TextColor;
     TextPadding = style.TextPadding;
     TextAlign   = style.TextAlign;
     Texture     = style.Texture;
     TextureRect = style.TextureRect;
     Tiling      = style.Tiling;
     Grid        = style.Grid;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            fCamera.Update(gameTime);

            float seconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (fBillboard1 == null)
            {
                InitBillboard();
            }
            if (this.Manager.KeyPressed(Keys.V))
            {
                fUseVertexBuffer            = !fUseVertexBuffer;
                fBillboard1.UseVertexBuffer = fBillboard2.UseVertexBuffer = fBillboard3.UseVertexBuffer = fUseVertexBuffer;
            }
            else if (this.Manager.KeyPressed(Keys.H))
            {
                fHalted = !fHalted;
            }
            else if (this.Manager.KeyPressed(Keys.M))
            {
                if (fDrawMode == BillboardMode.PointList)
                {
                    fDrawMode = BillboardMode.Quad;
                }
                else
                {
                    fDrawMode = BillboardMode.PointList;
                }
                fBillboard1.Mode = fBillboard2.Mode = fBillboard3.Mode = fDrawMode;
                InitBillboard();
            }
            else if (this.Manager.KeyPressed(Keys.T))
            {
                if (fTextureMode == TextureMode.Faces)
                {
                    fTextureMode = TextureMode.Test;
                }
                else
                {
                    fTextureMode = TextureMode.Faces;
                }
            }

            base.Update(gameTime);
        }
Exemplo n.º 8
0
 public Texture2D(Device device, TextureMode mode)
     : base(device)
 {
     deviceD3D12 = device;
     handle      = Texture.Orbital_Video_D3D12_Texture_Create(device.handle, mode);
 }
Exemplo n.º 9
0
 public static string TextureModeToString(TextureMode mode) => mode switch
 {
Exemplo n.º 10
0
 public static extern IntPtr Orbital_Video_D3D12_Texture_Create(IntPtr device, TextureMode mode);
Exemplo n.º 11
0
 public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, TextureMode mode, MSAALevel msaaLevel, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility)
 {
     throw new NotImplementedException();
 }
        public void RemoveTextureMode(TextureMode mode)
        {
            PrevalidateMaterial();

            _currentMaterial = _currentMaterial.RemoveTextureMode(mode);
        }
	    public void SetTextureMode(TextureMode mode)
	    {
	        PrevalidateMaterial();

            _currentMaterial = _currentMaterial.UpdateTextureMode(mode);
	    }
        void GUI()
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);


            ShowTerrainPref = EditorGUILayout.Foldout(ShowTerrainPref, " Terrain Prefs: ");

            if (ShowTerrainPref)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Heightmap Resolution     ", GUILayout.ExpandWidth(false));
                heightmapResolution_index = EditorGUILayout.Popup(heightmapResolution_index, heightmapResolutionsSrt);
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Detail Resolution            ", GUILayout.ExpandWidth(false));
                detailResolution_index = EditorGUILayout.Popup(detailResolution_index, availableHeightSrt);
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Resolution Per Patch       ", GUILayout.ExpandWidth(false));
                resolutionPerPatch_index = EditorGUILayout.Popup(resolutionPerPatch_index, availableHeightsResolutionPrePectSrt);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Base Map Resolution       ", GUILayout.ExpandWidth(false));
                baseMapResolution_index = EditorGUILayout.Popup(baseMapResolution_index, availableHeightSrt);
                GUILayout.EndHorizontal();
            }

            ShowTexturePref = EditorGUILayout.Foldout(ShowTexturePref, " Texture Prefs : ");

            if (ShowTexturePref)
            {
                textureMode = (TextureMode)EditorGUILayout.EnumPopup(" Texturing Mode : ", textureMode);


                if (textureMode == TextureMode.WithTexture)
                {
                    textureWidth      = EditorGUILayout.IntField("Texture Width", textureWidth, GUILayout.ExpandWidth(false));
                    textureHeight     = EditorGUILayout.IntField("Texture Height", textureHeight, GUILayout.ExpandWidth(false));
                    textureEmptyColor = EditorGUILayout.ColorField("Texture Empty Color", textureEmptyColor, GUILayout.ExpandWidth(false));
                }
            }

            ShowSetTerrainPref = EditorGUILayout.Foldout(ShowSetTerrainPref, " Terrain Heightmap / Parametres: ");

            if (ShowSetTerrainPref)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Set Terrain File (*.Flt) :", GUILayout.ExpandWidth(false));
                TerrainFile = EditorGUILayout.ObjectField(TerrainFile, typeof(UnityEngine.Object), GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();

                terrainElevation = (TerrainElevation)EditorGUILayout.EnumPopup("Terrain Elevation Mode : ", terrainElevation);

                if (terrainElevation == TerrainElevation.RealWorldElevation)
                {
                }
                else
                if (terrainElevation == TerrainElevation.ExaggerationTerrain)
                {
                    TerrainExaggeration = EditorGUILayout.Slider(TerrainExaggeration, 0, 1);
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Terrain Scale X: ", GUILayout.ExpandWidth(false));
                terrainScale.x = EditorGUILayout.FloatField(terrainScale.x, GUILayout.ExpandWidth(false));
                GUILayout.Label("Y: ", GUILayout.ExpandWidth(false));
                terrainScale.y = EditorGUILayout.FloatField(terrainScale.y, GUILayout.ExpandWidth(false));
                GUILayout.Label("Z: ", GUILayout.ExpandWidth(false));
                terrainScale.z = EditorGUILayout.FloatField(terrainScale.z, GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();

                RemovePrvTerrain = EditorGUILayout.Toggle("Remove Previous Terrain :", RemovePrvTerrain);


                GUILayout.BeginHorizontal();
                GUILayout.Label("Enable Terrain Height Smoother  : ", GUILayout.ExpandWidth(false));
                UseTerrainHeightSmoother = EditorGUILayout.Toggle("", UseTerrainHeightSmoother);
                GUILayout.EndHorizontal();



                if (UseTerrainHeightSmoother)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Terrain Height Smooth Factor   :", GUILayout.ExpandWidth(false));
                    TerrainHeightSmoothFactor = EditorGUILayout.Slider(TerrainHeightSmoothFactor, 0.0f, 0.3f, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Enable Terrain Surface Smoother : ", GUILayout.ExpandWidth(false));
                UseTerrainSurfaceSmoother = EditorGUILayout.Toggle("", UseTerrainSurfaceSmoother);
                GUILayout.EndHorizontal();


                if (UseTerrainSurfaceSmoother)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Terrain Surface Smooth Factor :", GUILayout.ExpandWidth(false));
                    TerrainSurfaceSmoothFactor = EditorGUILayout.IntSlider(TerrainSurfaceSmoothFactor, 1, 15, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();
                }
            }



            ShowOSMVectorData = EditorGUILayout.Foldout(ShowOSMVectorData, " Generate OSM Vector Data : ");

            if (ShowOSMVectorData)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Enable Tree Generation :  ", GUILayout.ExpandWidth(false));
                EnableTreeGeneration = EditorGUILayout.Toggle("", EnableTreeGeneration);
                GUILayout.EndHorizontal();

                if (EnableTreeGeneration)
                {
                    //Tree Density
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Tree Density :", GUILayout.ExpandWidth(false));
                    TreeDensity = EditorGUILayout.Slider(TreeDensity, 1, 100, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Tree Scale Factor
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Tree Scale Factor :", GUILayout.ExpandWidth(false));
                    TreeScaleFactor = EditorGUILayout.Slider(TreeScaleFactor, 1, 10, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Tree Random Scale Factor
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Tree Random Scale Factor :", GUILayout.ExpandWidth(false));
                    TreeRandomScaleFactor = EditorGUILayout.Slider(TreeRandomScaleFactor, 0.1f, 1, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();
                    //Tree Distance
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Tree Distance :", GUILayout.ExpandWidth(false));
                    TreeDistance = EditorGUILayout.Slider(TreeDistance, 1, 5000, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Tree BillBoard Start Distance
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Tree BillBoard Start Distance :", GUILayout.ExpandWidth(false));
                    BillBoardStartDistance = EditorGUILayout.Slider(BillBoardStartDistance, 1, 2000, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Tree Prefabs List
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Trees : ", GUILayout.ExpandWidth(false));

                    ScriptableObject   target          = this;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("TreePrefabs");

                    EditorGUILayout.PropertyField(stringsProperty, true);
                    so.ApplyModifiedProperties();

                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Enable Grass Generation : ", GUILayout.ExpandWidth(false));
                EnableGrassGeneration = EditorGUILayout.Toggle("", EnableGrassGeneration);
                GUILayout.EndHorizontal();

                if (EnableGrassGeneration)
                {
                    //Grass Density
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Grass Density :", GUILayout.ExpandWidth(false));
                    GrassDensity = EditorGUILayout.Slider(GrassDensity, 1, 100, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Grass Scale Factor
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Grass Scale Factor :", GUILayout.ExpandWidth(false));
                    GrassScaleFactor = EditorGUILayout.Slider(GrassScaleFactor, 0.1f, 3, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Detail Distance
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Detail Distance :", GUILayout.ExpandWidth(false));
                    DetailDistance = EditorGUILayout.Slider(DetailDistance, 10f, 400, GUILayout.ExpandWidth(true));
                    GUILayout.EndHorizontal();

                    //Tree Prefabs List
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Grass : ", GUILayout.ExpandWidth(false));

                    ScriptableObject   target          = this;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("GrassPrefabs");

                    EditorGUILayout.PropertyField(stringsProperty, true);
                    so.ApplyModifiedProperties();

                    GUILayout.EndHorizontal();
                }
            }



            if (GUILayout.Button("Generate Terrain"))
            {
                heightmapResolution = heightmapResolutions[heightmapResolution_index];
                detailResolution    = availableHeights[detailResolution_index];
                resolutionPerPatch  = availableHeightsResolutionPrePec[resolutionPerPatch_index];
                baseMapResolution   = availableHeights[baseMapResolution_index];


                TerrainFilePath = Path.Combine(Path.GetDirectoryName(Application.dataPath), AssetDatabase.GetAssetPath(TerrainFile));
                Initialization();
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 15
0
 public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility)
 {
     return(activeDevice.CreateRenderTexture2D(width, height, format, usage, data, mode, stencilUsage, depthStencilFormat, depthStencilMode, allowRandomAccess, nodeVisibility));
 }
Exemplo n.º 16
0
 public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, MultiGPUNodeResourceVisibility nodeVisibility)
 {
     return(activeDevice.CreateRenderTexture2D(width, height, format, usage, data, mode, nodeVisibility));
 }
Exemplo n.º 17
0
 public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, TextureMode mode, MSAALevel msaaLevel, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility)
 {
     return(activeDevice.CreateRenderTexture2D(width, height, format, usage, mode, msaaLevel, allowRandomAccess, nodeVisibility));
 }
Exemplo n.º 18
0
 public abstract Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, MultiGPUNodeResourceVisibility nodeVisibility);
Exemplo n.º 19
0
 public abstract Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility);
Exemplo n.º 20
0
 public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 21
0
 public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, MultiGPUNodeResourceVisibility nodeVisibility)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
 public void BindTexture(string texture, TextureMode mode)
 {
     BindTexture(texture);
 }
Exemplo n.º 23
0
 protected override void ReadAttributesXml(XmlReader reader)
 {
     base.ReadAttributesXml(reader);
     mode      = (TextureMode)Enum.Parse(typeof(TextureMode), (reader["mode"] ?? "SPHERE").Replace("-", "_"));
     parameter = reader["parameter"]?.Split(' ').Select(p => float.Parse(p, NumberStyles.Any, CultureInfo.InvariantCulture)).ToArray() ?? new float[0];
 }
        void OnGUI()
        {
            if (m_Mesh == null)
            {
                GUILayout.Label("Select a GameObject in the scene with a MeshRenderer");
                return;
            }
            Event e = Event.current;

            m_MousePos    = e.mousePosition;
            m_MousePos.x -= m_ViewPort.x;
            m_MousePos.y -= m_ViewPort.y;
            var UV = (m_MousePos - m_Offset) / m_Width;

            UV.y = 1.0f - UV.y;

            var TexArea = new Rect(m_Offset.x, m_Offset.y, m_Width, m_Width);

            if (e.type == EventType.Layout)
            {
                m_Texture = m_Submesh.m_Material.mainTexture;
            }

            GUILayout.BeginHorizontal();
            for (int i = 0; i < m_Submeshes.Count; i++)
            {
                if (SelectButton("Submesh_" + i, m_Submesh == m_Submeshes[i]))
                {
                    m_Submesh = m_Submeshes[i];
                }
            }
            if (GUILayout.Toggle(m_ShowTriangleList, "TriangleList", "Button", GUILayout.ExpandWidth(false)))
            {
                m_ShowTriangleList = true;
                SceneView.RepaintAll();
            }
            else
            {
                m_ShowTriangleList = false;
                SceneView.RepaintAll();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            DrawZoomGUI();
            m_DrawLines     = GUILayout.Toggle(m_DrawLines, "DrawLines", "Button", GUILayout.Width(100));
            m_DrawTriangles = GUILayout.Toggle(m_DrawTriangles, "DrawTriangles", "Button", GUILayout.Width(100));
            if (GUILayout.Button("" + m_TextureMode))
            {
                while (true)
                {
                    m_TextureMode = m_TextureMode + 1;
                    if ((int)m_TextureMode > 6)
                    {
                        m_TextureMode = 0;
                        break;
                    }

                    if (("" + m_TextureMode).Length > 2)
                    {
                        break;
                    }
                }
            }

            bool tmpWrap = GUILayout.Toggle(m_ShowWrap, "Wrap", "Button", GUILayout.Width(50));

            if (tmpWrap != m_ShowWrap)
            {
                if (e.button == 0)
                {
                    m_ShowWrap = tmpWrap;
                }
                else
                {
                    m_WrapCount = 5;
                }
            }
            if (GUILayoutUtility.GetLastRect().Contains(e.mousePosition) && e.type == EventType.ScrollWheel)
            {
                if (e.delta.y < 0)
                {
                    m_WrapCount = Mathf.Max(m_WrapCount - 1, 0);
                }
                else
                {
                    m_WrapCount = Mathf.Min(m_WrapCount + 1, 5000);
                }
            }

            m_ClearBackGround = GUILayout.Toggle(m_ClearBackGround, "ClearBK", "Button", GUILayout.Width(60));
            m_BackGroundColor = EditorGUILayout.ColorField(m_BackGroundColor, GUILayout.Width(50));

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            var oldColor = GUI.color;

            for (int i = 0; i < m_UV.Count; i++)
            {
                if (m_UV[i] == null)
                {
                    GUI.color = new Color(1, 0.6f, 0.6f, 0.8f);
                    GUILayout.Label("No uv" + i, "Button");
                }
                else
                {
                    GUI.color = oldColor;
                    if (SelectButton("uv" + i, m_CurrentUVSet == i))
                    {
                        m_CurrentUVSet = i;
                    }
                }
            }
            GUI.color = oldColor;
            GUILayout.Label("Front:", GUILayout.Width(50));
            m_FrontFaceColor = EditorGUILayout.ColorField(m_FrontFaceColor, GUILayout.Width(50));
            GUILayout.Label("Back:", GUILayout.Width(50));
            m_BackFaceColor = EditorGUILayout.ColorField(m_BackFaceColor, GUILayout.Width(50));

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Offset: " + m_Offset);
            GUILayout.Label("viewSize: " + m_ViewPort);

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            var R = GUILayoutUtility.GetRect(50, 10000, 50, 10000);

            if (m_ShowTriangleList)
            {
                DrawTriangleList();
            }
            GUILayout.EndHorizontal();
            if (e.type != EventType.Layout)
            {
                m_ViewPort = R;
            }

            if (e.type == EventType.MouseDrag && GUIUtility.hotControl == 0)
            {
                m_Offset += e.delta;
                MyRepaint();
            }
            if (e.type == EventType.MouseMove)
            {
                Repaint();
            }

            if (e.type == EventType.Repaint)
            {
                Drawing.EditorWindowViewport(position, m_ViewPort);
                if (m_ClearBackGround)
                {
                    GL.Clear(true, true, m_BackGroundColor);
                }
                if (m_Texture != null)
                {
                    var old = m_Texture.filterMode;

                    if (m_TextureMode != TextureMode.HideTexture)
                    {
                        if (((int)m_TextureMode & 4) != 0)
                        {
                            m_Texture.filterMode = FilterMode.Bilinear;
                        }
                        else
                        {
                            m_Texture.filterMode = FilterMode.Point;
                        }
                        if (m_ShowWrap)
                        {
                            Rect Rtmp   = TexArea;
                            var  center = Rtmp.center;
                            Rtmp.width  *= 1 + m_WrapCount * 2;
                            Rtmp.height *= 1 + m_WrapCount * 2;
                            Rtmp.center  = center;
                            GUI.color    = new Color(1, 1, 1, 0.5f * m_BackGroundColor.a);
                            Graphics.DrawTexture(Rtmp, m_Texture, new Rect(-m_WrapCount, -m_WrapCount, 1 + m_WrapCount * 2, 1 + m_WrapCount * 2), 0, 0, 0, 0, GUI.color, m_TextureMapAlphaOnly);
                        }
                        GUI.color = new Color(1, 1, 1, /*0.5f */ m_BackGroundColor.a);
                        Graphics.DrawTexture(TexArea, m_Texture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, m_TextureMapNormal);
                    }
                    m_Texture.filterMode = old;
                }

                Drawing.BeginGL(new Color(1, 1, 1, 0.2f), GL.LINES);
                if (m_ShowWrap)
                {
                    for (int i = -m_WrapCount; i <= m_WrapCount + 1; i++)
                    {
                        GL.Vertex(new Vector2(m_Offset.x + m_Width * i, 0));
                        GL.Vertex(new Vector2(m_Offset.x + m_Width * i, 10000));
                        GL.Vertex(new Vector2(0, m_Offset.y + m_Width * i));
                        GL.Vertex(new Vector2(10000, m_Offset.y + m_Width * i));
                    }
                }
                GL.Color(new Color(1, 1, 0, 0.2f));
                for (int i = 0; i < 2; i++)
                {
                    GL.Vertex(new Vector2(m_Offset.x + m_Width * i, 0));
                    GL.Vertex(new Vector2(m_Offset.x + m_Width * i, 10000));
                    GL.Vertex(new Vector2(0, m_Offset.y + m_Width * i));
                    GL.Vertex(new Vector2(10000, m_Offset.y + m_Width * i));
                }
                GL.End();

                if (m_CurrentUVSet >= 0)
                {
                    if (m_DrawLines)
                    {
                        var tmpRand = new System.Random(5);
                        Drawing.BeginGL(Color.red, GL.LINES);
                        for (int i = 0; i < m_Submesh.m_Indices.Length; i += 3)
                        {
                            GL.Color(new Color((float)tmpRand.NextDouble(), (float)tmpRand.NextDouble(), (float)tmpRand.NextDouble()));
                            var P1 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[i + 0]];
                            var P2 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[i + 1]];
                            var P3 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[i + 2]];
                            P1.y = 1.0f - P1.y;
                            P2.y = 1.0f - P2.y;
                            P3.y = 1.0f - P3.y;
                            P1   = Vector2.Scale(P1, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                            P2   = Vector2.Scale(P2, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                            P3   = Vector2.Scale(P3, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                            GL.Vertex(P1);
                            GL.Vertex(P2);
                            GL.Vertex(P2);
                            GL.Vertex(P3);
                            GL.Vertex(P3);
                            GL.Vertex(P1);
                        }
                        GL.End();
                    }

                    if (m_DrawTriangles)
                    {
                        var tmpRand = new System.Random(5);
                        Drawing.BeginGL(new Color(1, 0, 0, 0.2f), GL.TRIANGLES);
                        for (int i = 0; i < m_Submesh.m_Indices.Length; i += 3)
                        {
                            var P1 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[i + 0]];
                            var P2 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[i + 1]];
                            var P3 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[i + 2]];
                            P1.y = 1.0f - P1.y;
                            P2.y = 1.0f - P2.y;
                            P3.y = 1.0f - P3.y;
                            P1   = Vector2.Scale(P1, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                            P2   = Vector2.Scale(P2, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                            P3   = Vector2.Scale(P3, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                            var FColor = m_FrontFaceColor;
                            FColor  *= 0.5f + (float)(tmpRand.NextDouble() * 0.5);
                            FColor.a = m_FrontFaceColor.a;
                            var BColor = m_BackFaceColor;
                            BColor  *= 0.5f + (float)(tmpRand.NextDouble() * 0.5);
                            BColor.a = m_BackFaceColor.a;
                            GL.Color(FColor);
                            GL.Vertex(P1);
                            GL.Vertex(P2);
                            GL.Vertex(P3);

                            GL.Color(BColor);

                            GL.Vertex(P2);
                            GL.Vertex(P1);
                            GL.Vertex(P3);
                        }
                        GL.End();
                    }

                    if (m_SelectedTriangle >= 0 && m_SelectedTriangle < m_Triangles.Length)
                    {
                        Drawing.BeginGL(new Color(1, 0, 0, 0.2f), GL.TRIANGLES);

                        var P1 = m_UV[m_CurrentUVSet][m_Triangles[m_SelectedTriangle * 3 + 0]];
                        var P2 = m_UV[m_CurrentUVSet][m_Triangles[m_SelectedTriangle * 3 + 1]];
                        var P3 = m_UV[m_CurrentUVSet][m_Triangles[m_SelectedTriangle * 3 + 2]];
                        P1.y = 1.0f - P1.y;
                        P2.y = 1.0f - P2.y;
                        P3.y = 1.0f - P3.y;
                        P1   = Vector2.Scale(P1, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                        P2   = Vector2.Scale(P2, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                        P3   = Vector2.Scale(P3, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);

                        GL.Color(new Color(0, 0, 1, 0.5f));

                        GL.Vertex(P2);
                        GL.Vertex(P1);
                        GL.Vertex(P3);

                        GL.Color(new Color(1, 0, 1, 0.5f));

                        GL.Vertex(P1);
                        GL.Vertex(P2);
                        GL.Vertex(P3);

                        GL.End();
                    }

                    if (m_SelectedVertex >= 0 && m_Submesh != null && m_Submesh.m_Indices != null)
                    {
                        m_CurrentUVSet   = Mathf.Clamp(m_CurrentUVSet, 0, m_UV.Count - 1);
                        m_SelectedVertex = Mathf.Clamp(m_SelectedVertex, 0, m_Submesh.m_Indices.Length - 1);
                        var P1 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[m_SelectedVertex]];
                        P1.y = 1.0f - P1.y;
                        P1   = Vector2.Scale(P1, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);

                        Drawing.BeginGL(new Color(1, 0, 0, 0.2f), GL.QUADS);

                        GL.Color(new Color(1, 1, 1, 0.7f));

                        GL.Vertex(P1 - Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P1 + Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P1 + Vector2.up * 5 - Vector2.right * 5);
                        GL.Vertex(P1 - Vector2.up * 5 - Vector2.right * 5);

                        GL.End();
                    }
                    if (m_SelectedVertTriangle >= 0 && m_Submesh != null && m_Submesh.m_Indices != null)
                    {
                        m_CurrentUVSet         = Mathf.Clamp(m_CurrentUVSet, 0, m_UV.Count - 1);
                        m_SelectedVertTriangle = Mathf.Clamp(m_SelectedVertTriangle, 0, m_Submesh.m_Indices.Length / 3 - 1);
                        var P1 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[m_SelectedVertTriangle * 3 + 0]];
                        var P2 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[m_SelectedVertTriangle * 3 + 1]];
                        var P3 = m_UV[m_CurrentUVSet][m_Submesh.m_Indices[m_SelectedVertTriangle * 3 + 2]];
                        P1.y = 1.0f - P1.y;
                        P2.y = 1.0f - P2.y;
                        P3.y = 1.0f - P3.y;
                        P1   = Vector2.Scale(P1, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                        P2   = Vector2.Scale(P2, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);
                        P3   = Vector2.Scale(P3, new Vector2(TexArea.width, TexArea.height)) + new Vector2(TexArea.x, TexArea.y);

                        Drawing.BeginGL(new Color(1, 0, 0, 0.2f), GL.QUADS);

                        GL.Color(new Color(1, 1, 1, 0.7f));

                        GL.Vertex(P1 - Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P1 + Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P1 + Vector2.up * 5 - Vector2.right * 5);
                        GL.Vertex(P1 - Vector2.up * 5 - Vector2.right * 5);

                        GL.Vertex(P2 - Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P2 + Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P2 + Vector2.up * 5 - Vector2.right * 5);
                        GL.Vertex(P2 - Vector2.up * 5 - Vector2.right * 5);

                        GL.Vertex(P3 - Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P3 + Vector2.up * 5 + Vector2.right * 5);
                        GL.Vertex(P3 + Vector2.up * 5 - Vector2.right * 5);
                        GL.Vertex(P3 - Vector2.up * 5 - Vector2.right * 5);

                        GL.End();
                    }
                }

                if (e.control)
                {
                    Drawing.BeginGL(new Color(0, 1, 0, 0.5f), GL.LINES);
                    GL.Vertex(m_MousePos + Vector2.up * 7);
                    GL.Vertex(m_MousePos - Vector2.up * 7);
                    GL.Vertex(m_MousePos + Vector2.right * 7);
                    GL.Vertex(m_MousePos - Vector2.right * 7);
                    m_CurrentIndex = FindClosestVertex(UV);
                    if (m_CurrentIndex >= 0)
                    {
                        var p = m_UV[m_CurrentUVSet][m_CurrentIndex];
                        p.y = 1.0f - p.y;
                        var pDraw = p * m_Width + m_Offset;

                        GL.Color(new Color(1, 1, 1, 0.8f));
                        GL.Vertex(pDraw + Vector2.up * 70);
                        GL.Vertex(pDraw - Vector2.up * 70);
                        GL.Vertex(pDraw + Vector2.right * 70);
                        GL.Vertex(pDraw - Vector2.right * 70);
                        GL.Vertex(m_MousePos);
                        GL.Vertex(pDraw);

                        GL.Color(new Color(1, 1, 1, 0.3f));
                        foreach (var vert in Drawing.GetCircleLinePoints(m_MousePos, (pDraw - m_MousePos).magnitude, 60))
                        {
                            GL.Vertex(vert);
                        }
                        GL.End();
                        GUI.color = new Color(1, 1, 1, 0.8f);
                        GUI.Label(new Rect(m_MousePos.x + 10, m_MousePos.y - 25 - 2, 200, 25), "closest U:" + p.x.ToString("0.0000") + " V:" + p.y.ToString("0.0000"), "box");
                    }
                    else
                    {
                        GL.End();
                    }

                    GUI.Label(new Rect(m_MousePos.x + 10, m_MousePos.y + 2, 200, 25), "mouse U:" + UV.x.ToString("0.0000") + " V:" + UV.y.ToString("0.0000"), "box");
                    EditorGUIUtility.AddCursorRect(m_ViewPort, (MouseCursor)(-1));
                    SceneView.RepaintAll();
                }
            }
            else if (e.type == EventType.KeyDown)
            {
                if (m_Submesh != null && m_Submesh.m_Indices != null)
                {
                    if (e.keyCode == KeyCode.UpArrow)
                    {
                        if (m_SelectedVertex >= 0)
                        {
                            m_SelectedVertex = Mathf.Clamp(m_SelectedVertex - 3, 0, m_Submesh.m_Indices.Length - 1);
                        }
                        if (m_SelectedVertTriangle >= 0)
                        {
                            m_SelectedVertTriangle = Mathf.Clamp(m_SelectedVertTriangle - 1, 0, m_Submesh.m_Indices.Length / 3 - 1);
                        }
                    }
                    else if (e.keyCode == KeyCode.DownArrow)
                    {
                        if (m_SelectedVertex >= 0)
                        {
                            m_SelectedVertex = Mathf.Clamp(m_SelectedVertex + 3, 0, m_Submesh.m_Indices.Length - 1);
                        }
                        if (m_SelectedVertTriangle >= 0)
                        {
                            m_SelectedVertTriangle = Mathf.Clamp(m_SelectedVertTriangle + 1, 0, m_Submesh.m_Indices.Length / 3 - 1);
                        }
                    }
                    else if (e.keyCode == KeyCode.LeftArrow)
                    {
                        if (m_SelectedVertex >= 0)
                        {
                            m_SelectedVertex = Mathf.Clamp(m_SelectedVertex - 1, 0, m_Submesh.m_Indices.Length - 1);
                        }
                    }
                    else if (e.keyCode == KeyCode.RightArrow)
                    {
                        if (m_SelectedVertex >= 0)
                        {
                            m_SelectedVertex = Mathf.Clamp(m_SelectedVertex + 1, 0, m_Submesh.m_Indices.Length - 1);
                        }
                    }
                    MyRepaint();
                }
            }
            if (GUI.changed)
            {
                MyRepaint();
            }
        }
Exemplo n.º 25
0
        public override Texture2DBase CreateTexture2D(TextureFormat format, int width, int height, byte[] data, TextureMode mode)
        {
            var abstraction = new Texture2D(this, mode);

            if (!abstraction.Init(format, width, height, data))
            {
                abstraction.Dispose();
                throw new Exception("Failed to create Texture2D");
            }
            return(abstraction);
        }
Exemplo n.º 26
0
 public abstract Texture2DBase CreateTexture2D(TextureFormat format, int width, int height, byte[] data, TextureMode mode);
Exemplo n.º 27
0
 public Texture(string file, TextureMode mode)
 {
     this.FilePath = file;
     this.Mode = mode;
 }
Exemplo n.º 28
0
        public override Texture2DBase CreateTexture2D(int width, int height, TextureFormat format, byte[] data, TextureMode mode, MultiGPUNodeResourceVisibility nodeVisibility)
        {
            var abstraction = new Texture2D(this, mode);

            if (!abstraction.Init(width, height, format, data, nodeVisibility))
            {
                abstraction.Dispose();
                throw new Exception("Failed to create Texture2D");
            }
            return(abstraction);
        }
Exemplo n.º 29
0
 public void SetTextureMode(TextureMode mode) => _jsRuntime.InvokeVoid(
     _p5InvokeFunction,
     "textureMode",
     TextureModeToString(mode)
     );
Exemplo n.º 30
0
        public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, TextureMode mode, MSAALevel msaaLevel, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility)
        {
            var abstraction = new RenderTexture2D(this, usage, mode);

            if (!abstraction.Init(width, height, format, msaaLevel, allowRandomAccess, nodeVisibility))
            {
                abstraction.Dispose();
                throw new Exception("Failed to create RenderTexture2D");
            }
            return(abstraction);
        }
Exemplo n.º 31
0
        public virtual void DrawSectionMisc() // General Tab
        {
            #region Extension IPointer Events
            bool extensionIPointerEventsSupport = targetAsSSAA.ExtensionIPointerEvents.IsSupported();
            if (extensionIPointerEventsSupport)
            {
                GUI.color = extensionIPointerEvents.FindPropertyRelative("enabled").boolValue ? new Color(.5f, 1f, .5f) : new Color(.8f, .8f, .8f);
            }
            else
            {
                GUI.color = new Color(1f, .3f, .3f);
            }
            EditorGUILayout.BeginHorizontal(styleHeader);
            {
                GUI.color = Color.white;
                EditorGUI.indentLevel++;
                extensionIPointerEvents.FindPropertyRelative("inspectorFoldout").boolValue = EditorGUILayout.Foldout(
                    extensionIPointerEvents.FindPropertyRelative("inspectorFoldout").boolValue,
                    "Unity IPointerEvents Integration",
                    true,
                    styleFoldout);
                EditorGUI.indentLevel--;
                GUI.color = colorAccentPro;
                if (GUILayout.Button(extensionIPointerEvents.FindPropertyRelative("enabled").boolValue ? "Disable" : "Enable", GUILayout.MaxWidth(100), GUILayout.MinWidth(100)))
                {
                    targetAsSSAA.enabled = false;
                    targetAsSSAA.ExtensionIPointerEvents.enabled = !targetAsSSAA.ExtensionIPointerEvents.enabled;
                    targetAsSSAA.enabled = true;
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            if (extensionIPointerEvents.FindPropertyRelative("inspectorFoldout").boolValue)
            {
                EditorGUILayout.BeginVertical(styleContentBox);
                EditorGUILayout.HelpBox(SSAAExtensionPointerEventsSupport.description, MessageType.Info);
                EditorGUILayout.PropertyField(extensionIPointerEvents.FindPropertyRelative("eventsLayerMask"));
                EditorGUILayout.EndVertical();
            }
            #endregion

            #region Extension Post Processing Stack 2
            bool extensionPostProcessingStackSupport = targetAsSSAA.ExtensionPostProcessingStack.IsSupported();
            if (extensionPostProcessingStackSupport)
            {
                GUI.color = extensionPostProcessingStack.FindPropertyRelative("enabled").boolValue ? new Color(.5f, 1f, .5f) : new Color(.8f, .8f, .8f);
            }
            else
            {
                GUI.color = new Color(1f, .3f, .3f);
            }
            EditorGUILayout.BeginHorizontal(styleHeader);
            {
                GUI.color = Color.white;
                EditorGUI.indentLevel++;
                extensionPostProcessingStack.FindPropertyRelative("inspectorFoldout").boolValue = EditorGUILayout.Foldout(
                    extensionPostProcessingStack.FindPropertyRelative("inspectorFoldout").boolValue,
                    "Unity PostProcessing Stack V2 Integration",
                    true,
                    styleFoldout);

                EditorGUI.indentLevel--;
                GUI.color = colorAccentPro;
                if (extensionPostProcessingStackSupport)
                {
                    if (GUILayout.Button(extensionPostProcessingStack.FindPropertyRelative("enabled").boolValue ? "Disable" : "Enable", GUILayout.MaxWidth(100), GUILayout.MinWidth(100)))
                    {
                        targetAsSSAA.enabled = false;
                        targetAsSSAA.ExtensionPostProcessingStack.enabled = !targetAsSSAA.ExtensionPostProcessingStack.enabled;
                        targetAsSSAA.enabled = true;
                    }
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            if (extensionPostProcessingStack.FindPropertyRelative("inspectorFoldout").boolValue)
            {
                EditorGUILayout.BeginVertical(styleContentBox);
                if (extensionPostProcessingStackSupport)
                {
                    EditorGUILayout.HelpBox(SSAAExtensionPostProcessingStack2.description, MessageType.Info);
                    EditorGUILayout.PropertyField(extensionPostProcessingStack.FindPropertyRelative("updateFromOriginal"));
                    EditorGUILayout.PropertyField(extensionPostProcessingStack.FindPropertyRelative("lwrpLegacySupport"));
                }
                else
                {
                    EditorGUILayout.HelpBox(SSAAExtensionPostProcessingStack2.requirement, MessageType.Error);
                }
                EditorGUILayout.EndVertical();
            }
            #endregion

            #region Extension Cinemachine
            bool extensionCinemachineSupport = targetAsSSAA.ExtensionCinemachine.IsSupported();
            if (extensionCinemachineSupport)
            {
                GUI.color = extensionCinemachine.FindPropertyRelative("enabled").boolValue ? new Color(.5f, 1f, .5f) : new Color(.8f, .8f, .8f);
            }
            else
            {
                GUI.color = new Color(1f, .3f, .3f);
            }
            EditorGUILayout.BeginHorizontal(styleHeader);
            {
                GUI.color = Color.white;
                EditorGUI.indentLevel++;
                extensionCinemachine.FindPropertyRelative("inspectorFoldout").boolValue = EditorGUILayout.Foldout(
                    extensionCinemachine.FindPropertyRelative("inspectorFoldout").boolValue,
                    "Unity Cinemachine Integration",
                    true,
                    styleFoldout);

                EditorGUI.indentLevel--;
                GUI.color = colorAccentPro;
                if (extensionCinemachineSupport)
                {
                    if (GUILayout.Button(extensionCinemachine.FindPropertyRelative("enabled").boolValue ? "Disable" : "Enable", GUILayout.MaxWidth(100), GUILayout.MinWidth(100)))
                    {
                        targetAsSSAA.enabled = false;
                        targetAsSSAA.ExtensionCinemachine.enabled = !targetAsSSAA.ExtensionCinemachine.enabled;
                        if (targetAsSSAA.ExtensionCinemachine.enabled)
                        {
                            SymbolDefineUtils.AddDefine("SSAA_CINEMACHINE");
                        }
                        else
                        {
                            SymbolDefineUtils.RemoveDefine("SSAA_CINEMACHINE");
                        }
                        targetAsSSAA.enabled = true;
                    }
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            if (extensionCinemachine.FindPropertyRelative("inspectorFoldout").boolValue)
            {
                EditorGUILayout.BeginVertical(styleContentBox);
                if (extensionCinemachineSupport)
                {
                    EditorGUILayout.HelpBox(SSAAExtensionCinemachine.description, MessageType.Info);
                    EditorGUILayout.PropertyField(extensionCinemachine.FindPropertyRelative("updateFromOriginal"));
                }
                else
                {
                    EditorGUILayout.HelpBox(SSAAExtensionCinemachine.requirement, MessageType.Error);
                }
                EditorGUILayout.EndVertical();
            }
            #endregion

            // Draw Extensions
            EditorMacros.DrawHeader("Misc", styleHeader);
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginVertical(styleContentBox);
            // Handle render texture precision mode
            if (!Application.isPlaying)
            {
                currentMode = internalTextureFormat.enumValueIndex == (int)RenderTextureFormat.ARGBFloat ? TextureMode.Float : TextureMode.Half;
                var oldMode = currentMode;
                currentMode = (TextureMode)EditorGUILayout.EnumPopup(new GUIContent("Render Texture Precision"), currentMode);
                internalTextureFormat.enumValueIndex = currentMode == TextureMode.Half ? (int)RenderTextureFormat.ARGBHalf : (int)RenderTextureFormat.ARGBFloat;
                if (oldMode != currentMode)
                {
                    targetAsSSAA.Refresh();
                }
            }
            EditorGUILayout.PropertyField(inspectorShowHelp);
            EditorGUILayout.Separator();
            EditorGUI.indentLevel--;
            if (GUILayout.Button("Open online documentation"))
            {
                Application.OpenURL("https://github.com/MadGoat-Studio/MadGoat-SSAA-Resolution-Scale/wiki");
            }

            EditorGUILayout.EndVertical();

            // Draw Social Media
            EditorMacros.DrawSocial(styleHeader, styleContentBox);
        }
Exemplo n.º 32
0
        public override Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, byte[] data, TextureMode mode, StencilUsage stencilUsage, DepthStencilFormat depthStencilFormat, DepthStencilMode depthStencilMode, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility)
        {
            var abstraction = new RenderTexture2D(this, usage, mode);

            if (!abstraction.Init(width, height, format, data, stencilUsage, depthStencilFormat, depthStencilMode, allowRandomAccess, nodeVisibility))
            {
                abstraction.Dispose();
                throw new Exception("Failed to create RenderTexture2D");
            }
            return(abstraction);
        }
Exemplo n.º 33
0
 public override Texture2DBase CreateTexture2D(TextureFormat format, int width, int height, byte[] data, TextureMode mode)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 34
0
 public abstract Texture2DBase CreateRenderTexture2D(int width, int height, TextureFormat format, RenderTextureUsage usage, TextureMode mode, MSAALevel msaaLevel, bool allowRandomAccess, MultiGPUNodeResourceVisibility nodeVisibility);