/// <summary>
        /// Generate the custom splatPrototypes for a Heatmap.
        /// </summary>
        /// <param name="datatexture"></param>
        /// <returns></returns>
        SplatPrototype[] GenerateSplatPrototypesCustom(Heatmap datatexture)
        {
            List <SplatPrototype> splats = new List <SplatPrototype>();

            foreach (HeatmapSplatprototype layer in datatexture.heatmapSplatMaps)
            {
                SplatPrototype a = new SplatPrototype();

                a.normalMap  = layer.normalMap;
                a.metallic   = layer.metallic;
                a.smoothness = layer.smoothness;
                a.tileOffset = layer.tileOffset;
                a.tileSize   = layer.tileSizing;

                if (layer is ColorSplatMap)
                {
                    a.texture = TextureGenerator.GenerateTexture2D(((ColorSplatMap)layer).color, 1, 1);
                }
                else
                {
                    a.texture = ((TextureSplatMap)layer).texture;
                }

                splats.Add(a);
            }


            return(splats.ToArray());
        }
        // Displays the window as the "Edit texture" window, so clicking apply will edit the currently selected texture.
        public void ShowEditLayer(HeatmapSplatprototype layer)
        {
            splatMap = layer;
            if (splatMap is TextureSplatMap)
            {
                _textureToggle = false;
            }
            else
            {
                _textureToggle = true;
            }
            // Set the window title to "Edit Texture".
            this.titleContent = new GUIContent("Edit Texture");

            // We don't want the used to be able to make the window too small.
            this.minSize = new Vector2(200.0f, 300.0f);

            // Display the window as a utility window.
            this.ShowUtility();

            // Retrieve the correct parameters and display them in the window.
            if (layer is ColorSplatMap)
            {
                _albedoTexture = TextureGenerator.GenerateTexture2D(((ColorSplatMap)splatMap).color, 40, 40);
            }
            else
            {
                _albedoTexture = ((TextureSplatMap)splatMap).texture;
            }
            if (layer is TextureSplatMap)
            {
                try
                {
                    if (((TextureSplatMap)splatMap).texture != null)
                    {
                        _color = ((TextureSplatMap)splatMap).texture.GetPixel(0, 0);
                    }
                }
                catch (UnityException)
                {
                    _color = Color.black;
                }
            }
            else
            {
                _color = ((ColorSplatMap)splatMap).color;
            }

            _normalTexture = splatMap.normalMap;
            _smoothness    = splatMap.smoothness;
            _metallic      = splatMap.metallic;
            _tileOffset    = splatMap.tileOffset;
            _tileSize      = splatMap.tileSizing;


            // We launched in "Edit Texture" mode, so set editTexture to true.
            _editTexture = true;
        }
        // Generate Splat Prototypes for use as SplatMap Textures.
        SplatPrototype[] GenerateSplatPrototypesDefault()
        {
            // Create list to store splatPrototypes.
            List <SplatPrototype> heatMapColours = new List <SplatPrototype>();


            // Load the red colour into SplatProtoype.
            SplatPrototype red = new SplatPrototype();

            red.texture    = TextureGenerator.GenerateTexture2D(Color.red);
            red.tileSize   = new Vector2(10.0f, 10.0f);
            red.tileOffset = Vector2.zero;

            // Load the yellow colour into SplatProtoype.
            SplatPrototype yellow = new SplatPrototype();

            yellow.texture    = TextureGenerator.GenerateTexture2D(Color.yellow);
            yellow.tileSize   = new Vector2(10.0f, 10.0f);
            yellow.tileOffset = Vector2.zero;

            // Load the green colour into SplatProtoype.
            SplatPrototype green = new SplatPrototype();

            green.texture    = TextureGenerator.GenerateTexture2D(Color.green);
            green.tileSize   = new Vector2(10.0f, 10.0f);
            green.tileOffset = Vector2.zero;

            // Load the cyan colour into SplatProtoype.
            SplatPrototype cyan = new SplatPrototype();

            cyan.texture    = TextureGenerator.GenerateTexture2D(Color.cyan);
            cyan.tileSize   = new Vector2(10.0f, 10.0f);
            cyan.tileOffset = Vector2.zero;

            // Load the blue colour into SplatProtoype.
            SplatPrototype blue = new SplatPrototype();

            blue.texture    = TextureGenerator.GenerateTexture2D(Color.blue);
            blue.tileSize   = new Vector2(10.0f, 10.0f);
            blue.tileOffset = Vector2.zero;

            heatMapColours.Add(blue);
            heatMapColours.Add(cyan);
            heatMapColours.Add(green);
            heatMapColours.Add(yellow);
            heatMapColours.Add(red);


            // Return the Array of the list.
            return(heatMapColours.ToArray());
        }
        void OnGUI()
        {
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            _textureToggle = GUILayout.Toggle(_textureToggle, "Use Texture");
            _textureToggle = GUILayout.Toggle(!_textureToggle, "Use Color");
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label("");
            _color = EditorGUILayout.ColorField(_color);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            // Apply Albedo label above the other labels.
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Albedo (RGB)", GUILayout.Width(90.0f));
            _albedoTexture = (Texture2D)EditorGUILayout.ObjectField("", _albedoTexture, typeof(Texture2D), false, GUILayout.Width(90.0f));
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label("Normal", GUILayout.Width(90.0f));
            _normalTexture = (Texture2D)EditorGUILayout.ObjectField("", _normalTexture, typeof(Texture2D), false, GUILayout.Width(90.0f));
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(15.0f);

            // Create and position the Texture selector boxes horizontally next to each other.
            GUILayout.BeginHorizontal();
            GUILayout.Space(10.0f);
            GUILayout.EndHorizontal();

            // Leave a 10.0f pixel space for the next components.
            GUILayout.Space(10.0f);

            // Add the metallic slider.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Metallic", GUILayout.Width(73.0f));
            EditorGUI.BeginChangeCheck();
            _metallic = EditorGUILayout.Slider(_metallic, 0.0f, 1.0f);
            EditorGUI.EndChangeCheck();
            GUILayout.EndHorizontal();

            // Leave a 10.0f pixel space for the next components.
            GUILayout.Space(10.0f);

            // Add the smoothness slider.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Smoothness", GUILayout.Width(73.0f));
            _smoothness = EditorGUILayout.Slider(_smoothness, 0.0f, 1.0f);
            GUILayout.EndHorizontal();

            // Leave a 10.0f pixel space for the next components.
            GUILayout.Space(10.0f);

            // Create the 2x2 grid for adding tileSize and tileOffset.
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Space(20.0f);
            GUILayout.Label("x", GUILayout.Width(10.0f));
            GUILayout.Label("y", GUILayout.Width(10.0f));
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label("Size");
            _tileSize.x = EditorGUILayout.FloatField(_tileSize.x);
            _tileSize.y = EditorGUILayout.FloatField(_tileSize.y);
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label("Offset");
            _tileOffset.x = EditorGUILayout.FloatField(_tileOffset.x);
            _tileOffset.y = EditorGUILayout.FloatField(_tileOffset.y);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (_editTexture)
            {
                if (_textureToggle)
                {
                    _customInspector.UpdateSplatMapProperties(_metallic, _smoothness, _tileSize, _tileOffset, TextureGenerator.GenerateTexture2D(_color, 1, 1), _normalTexture);
                }
                else
                {
                    _customInspector.UpdateSplatMapProperties(_metallic, _smoothness, _tileSize, _tileOffset, _albedoTexture, _normalTexture);
                }
            }

            // Create and position the Apply button.
            if (GUI.Button(new Rect(this.position.width - 105.0f, this.position.height - 25.0f, 100.0f, 20.0f), "Apply"))
            {
                // Close the window.
                Apply();
                this.Close();
            }
        }