private Vector4 GetInputs(TextureInput texInput) { Vector4 states = Vector4.zero; for (int i = 0; i < 4; ++i) { var state = texInput.GetChannelInput((TextureChannel)i).enabled; states[i] = state ? 1f : 0f; } return(states); }
private Matrix4x4 GetOutputs(TextureInput texInput) { Matrix4x4 m = Matrix4x4.zero; for (int i = 0; i < 4; ++i) { Vector4 inChannel = Vector4.zero; var output = texInput.GetChannelInput((TextureChannel)i).output; inChannel[(int)output] = 1f; m.SetRow(i, inChannel); } return(m); }
private void OnGUI() { if (_preview == null) { return; } _windowScrollPos = EditorGUILayout.BeginScrollView(_windowScrollPos, false, false); RefreshItems(); GUILayout.Label(_windowTitle, TexturePackerStyles.Heading); GUILayout.BeginVertical(TexturePackerStyles.Section); GUILayout.Label("Inputs", TexturePackerStyles.Heading); foreach (TextureItem item in _items) { item.Draw(); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("+")) { TextureInput entry = new TextureInput(); _texturePacker.Add(entry); _items.Add(new TextureItem(entry)); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); int prevRes = _texturePacker.resolution; _texturePacker.resolution = 128; _preview.Draw(_texturePacker); _texturePacker.resolution = prevRes; GUILayout.Label("Options", TexturePackerStyles.Heading); GUILayout.BeginVertical(TexturePackerStyles.Section); textureFormat = (TextureFormat)EditorGUILayout.EnumPopup("> Format:", textureFormat); _texturePacker.resolution = EditorGUILayout.IntPopup("> Resolution:", _texturePacker.resolution, _textureResolutionsNames.ToArray(), _textureResolutions.ToArray()); GUILayout.EndVertical(); if (GUILayout.Button("Generate Texture", TexturePackerStyles.Button)) { string savePath = EditorUtility.SaveFilePanel("Save", Application.dataPath, "texture.png", textureFormat.ToString()); if (savePath != string.Empty) { Texture2D output = _texturePacker.Create(); if (textureFormat == TextureFormat.JPG) { File.WriteAllBytes(savePath, output.EncodeToJPG()); } else if (textureFormat == TextureFormat.PNG) { File.WriteAllBytes(savePath, output.EncodeToPNG()); } else if (textureFormat == TextureFormat.TGA) { File.WriteAllBytes(savePath, output.EncodeToTGA()); } else { File.WriteAllBytes(savePath, output.EncodeToEXR()); } AssetDatabase.Refresh(); } } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public TextureItem(TextureInput input) { this.input = input; }
public void Remove(TextureInput input) { _texInputs.Remove(input); }
public void Add(TextureInput entry) { _texInputs.Add(entry); }
public void Add(TextureInput entry) => TexInputs.Add(entry);