protected void DrawEditor()
        {
            bool delta = false;

            GUILayout.BeginVertical(GUILayout.MaxWidth(400f));
            GUILayout.BeginHorizontal();
            GUILayout.Label("Start Size");
            startSizeRange = UIUtils.Vector2InputField(GUILayoutUtility.GetRect(200f, 30f), startSizeRange, startSizeRangeString, GUI.skin.label, GUI.skin.textArea, out delta);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Emission Rate");
            emissionRateRange = UIUtils.Vector2InputField(GUILayoutUtility.GetRect(200f, 30f), emissionRateRange, emissionRateRangeString, GUI.skin.label, GUI.skin.textArea, out delta);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Emission Speed");
            emissionSpeedRange = UIUtils.Vector2InputField(GUILayoutUtility.GetRect(200f, 30f), emissionSpeedRange, emissionSpeedRangeString, GUI.skin.label, GUI.skin.textArea, out delta);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Lifetime Range");
            lifetimeRange = UIUtils.Vector2InputField(GUILayoutUtility.GetRect(200f, 30f), lifetimeRange, lifetimeRangeString, GUI.skin.label, GUI.skin.textArea, out delta);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        protected void DrawMaterialEdit()
        {
            float headerWidth = 120f;
            bool  delta       = false;

            GUILayout.Label("<b>Textures</b>");
            foreach (KeyValuePair <string, string> kvp in textureValues.ToList())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label($"{kvp.Key}", GUILayout.Width(headerWidth));

                GUILayout.Label("Texture Path");
                // Button to set that we are toggling the texture picker
                if (GUILayout.Button(kvp.Value))
                {
                    textureEdits[kvp.Key] = !textureEdits[kvp.Key];
                    Utils.Log($"[TP] Edit flag state {textureEdits[kvp.Key]}", LogType.UI);
                    // if yes, open the window
                    if (textureEdits[kvp.Key])
                    {
                        WaterfallUI.Instance.OpenTextureEditWindow(kvp.Key, textureValues[kvp.Key]);
                        Utils.Log("[TP] Open Window", LogType.UI);
                    }
                }

                // If picker open
                if (textureEdits[kvp.Key])
                {
                    // Close all other pickers
                    foreach (KeyValuePair <string, bool> kvp2 in textureEdits.ToList())
                    {
                        if (kvp2.Key != kvp.Key)
                        {
                            textureEdits[kvp2.Key] = false;
                        }
                    }

                    string newTex = WaterfallUI.Instance.GetTextureFromPicker();
                    if (newTex != kvp.Value)
                    {
                        textureValues[kvp.Key] = newTex;
                        Utils.Log($"[MaterialEditWindow] Changed {kvp.Key} to {textureValues[kvp.Key]}", LogType.UI);
                        model.SetTexture(matl, kvp.Key, textureValues[kvp.Key]);
                    }
                }

                GUILayout.EndHorizontal();
                delta = false;
                GUILayout.BeginHorizontal();
                GUILayout.Space(headerWidth);
                GUILayout.Label($"UV Scale", GUILayout.Width(headerWidth));
                textureScaleValues[kvp.Key] = UIUtils.Vector2InputField(GUILayoutUtility.GetRect(200f, 30f), textureScaleValues[kvp.Key], textureScaleStrings[kvp.Key], GUI.skin.label, GUI.skin.textArea, out delta);
                if (delta)
                {
                    model.SetTextureScale(matl, kvp.Key, textureScaleValues[kvp.Key]);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Space(headerWidth);
                GUILayout.Label($"UV Offset", GUILayout.Width(headerWidth));
                textureOffsetValues[kvp.Key] = UIUtils.Vector2InputField(GUILayoutUtility.GetRect(200f, 30f), textureOffsetValues[kvp.Key], textureOffsetStrings[kvp.Key], GUI.skin.label, GUI.skin.textArea, out delta);
                if (delta)
                {
                    model.SetTextureOffset(matl, kvp.Key, textureOffsetValues[kvp.Key]);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.Label("<b>Material Parameters</b>");
            foreach (KeyValuePair <string, Color> kvp in colorValues.ToList())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(kvp.Key, GUILayout.Width(headerWidth));
                GUILayout.Space(10);

                // Button to set that we are toggling the color picker
                if (GUILayout.Button("", GUILayout.Width(60)))
                {
                    colorEdits[kvp.Key] = !colorEdits[kvp.Key];
                    Utils.Log($"[CP] Edit flag state {colorEdits[kvp.Key]}", LogType.UI);
                    // if yes, open the window
                    if (colorEdits[kvp.Key])
                    {
                        WaterfallUI.Instance.OpenColorEditWindow(colorValues[kvp.Key]);
                        Utils.Log("[CP] Open Window", LogType.UI);
                    }
                }

                // If picker open
                if (colorEdits[kvp.Key])
                {
                    // Close all other pickers
                    foreach (KeyValuePair <string, bool> kvp2 in colorEdits.ToList())
                    {
                        if (kvp2.Key != kvp.Key)
                        {
                            colorEdits[kvp2.Key] = false;
                        }
                    }

                    Color c = WaterfallUI.Instance.GetColorFromPicker();
                    if (!c.IsEqualTo(colorValues[kvp.Key]))
                    {
                        colorValues[kvp.Key] = c;
                        delta = true;
                    }
                }
                Rect tRect = GUILayoutUtility.GetLastRect();
                tRect = new Rect(tRect.x + 3, tRect.y + 3, tRect.width - 6, tRect.height - 6);
                GUI.DrawTexture(tRect, colorTextures[kvp.Key]);



                //GUILayout.Space(10);
                //colorValues[kvp.Key] = UIUtils.ColorInputField(GUILayoutUtility.GetRect(200f, 30f), colorValues[kvp.Key], colorStrings[kvp.Key], GUI.skin.label, GUI.skin.textArea, out delta);
                if (delta)
                {
                    colorTextures[kvp.Key] = MaterialUtils.GenerateColorTexture(64, 32, colorValues[kvp.Key]);
                    model.SetColor(matl, kvp.Key, colorValues[kvp.Key]);
                }
                GUILayout.EndHorizontal();
            }
            foreach (KeyValuePair <string, float> kvp in floatValues.ToList())
            {
                float  sliderVal;
                string textVal;
                GUILayout.BeginHorizontal();
                GUILayout.Label(kvp.Key, GUILayout.Width(headerWidth));
                sliderVal = GUILayout.HorizontalSlider(floatValues[kvp.Key], WaterfallConstants.ShaderPropertyMap[kvp.Key].floatRange.x, WaterfallConstants.ShaderPropertyMap[kvp.Key].floatRange.y);

                if (sliderVal != floatValues[kvp.Key])
                {
                    floatValues[kvp.Key]  = sliderVal;
                    floatStrings[kvp.Key] = sliderVal.ToString();

                    model.SetFloat(matl, kvp.Key, floatValues[kvp.Key]);
                }

                textVal = GUILayout.TextArea(floatStrings[kvp.Key], GUILayout.Width(90f));


                if (textVal != floatStrings[kvp.Key])
                {
                    float outVal;
                    if (float.TryParse(textVal, out outVal))
                    {
                        floatValues[kvp.Key] = outVal;

                        model.SetFloat(matl, kvp.Key, floatValues[kvp.Key]);
                    }
                    floatStrings[kvp.Key] = textVal;
                }

                //float parsed = kvp.Value;
                //if (float.TryParse(textVal, out parsed))
                //{

                //  if (parsed != floatValues[kvp.Key])
                //  {
                //    floatValues[kvp.Key] = parsed;
                //    matl.SetFloat(kvp.Key, parsed);
                //  }
                //}

                GUILayout.EndHorizontal();
            }
            foreach (KeyValuePair <string, Vector4> kvp in vec4Values.ToList())
            {
                Vector3 vecVal;
                string  textVal;
                GUILayout.BeginHorizontal();
                GUILayout.Label(kvp.Key, GUILayout.Width(headerWidth));
                vecVal = UIUtils.Vector3InputField(GUILayoutUtility.GetRect(200f, 30f), kvp.Value, vec4Strings[kvp.Key], GUI.skin.label, GUI.skin.textArea);
                Vector4 temp = new Vector4(vecVal.x, vecVal.y, vecVal.z, 0f);
                if (temp != vec4Values[kvp.Key])
                {
                    vec4Values[kvp.Key] = temp;
                    matl.SetVector4(kvp.Key, temp);
                }


                GUILayout.EndHorizontal();
            }
        }