public static ReGradientGeneratorEditor Open(ReGradientData data) { var window = GetWindow <ReGradientGeneratorEditor>(); window.titleContent = new GUIContent("GradientGenerator"); window.minSize = new Vector2(520, 300); window.maxSize = new Vector2(520, 300); window.position = new Rect(window.position.position, window.minSize); window.SetupPreviewTexture(); window.currentGradient = data; return(window); }
void CreateNewGradient() { if (currentGradient.HasValue) { if (!PromptSave()) { return; } } currentGradient = new ReGradientData(); currentGradient.Size = new Vector2Int(256, 64); currentGradient.Nodes = new List <ReGradientNode>(); currentGradient.AddNode(Color.white, 0f); currentGradient.AddNode(Color.black, 1f); }
void Load() { if (!PromptSave()) { return; } var gradientFiles = System.IO.Directory.GetFiles(Application.dataPath, "*." + FileExt, System.IO.SearchOption.AllDirectories); if (gradientFiles.Length == 0) { return; } var gm = new GenericMenu(); foreach (var path in gradientFiles) { if (string.IsNullOrEmpty(path)) { continue; } gm.AddItem(new GUIContent(System.IO.Path.GetFileNameWithoutExtension(path)), false, () => { string content = System.IO.File.ReadAllText(path); if (string.IsNullOrEmpty(content)) { return; } currentGradient = JsonUtility.FromJson <ReGradientData>(content); selectedNode = -1; GeneratePreview(); }); } gm.ShowAsContext(); }