Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
        public void Draw()
        {
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

            EditorGUILayout.BeginHorizontal();

            _fold = EditorGUI.Foldout(GetFoldRect(), _fold, "Input");

            GUIStyle gearStyle = new GUIStyle("Icon.Options");

            GUILayout.FlexibleSpace();
            if (GUILayout.Button(gearStyle.normal.background, new GUIStyle("IconButton")))
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Remove"), false, data =>
                {
                    TextureItem item = data as TextureItem;
                    item.ToDelete    = true;
                }, this);

                menu.ShowAsContext();
            }

            using (new EditorGUI.IndentLevelScope(1))
            {
                EditorGUILayout.EndHorizontal();
                if (_fold)
                {
                    GUILayout.BeginHorizontal(TexturePackerStyles.Heading);

                    GUILayout.BeginVertical(TexturePackerStyles.Heading);

                    GUILayout.Label("Channels Selection:");

                    string [] channels = new string [] { "Red", "Green", "Blue", "Alpha" };

                    for (int i = 0; i < 4; ++i)
                    {
                        GUILayout.BeginHorizontal();

                        TextureChannel texChannel = (TextureChannel)i;

                        TextureChannelInput channelInput = input.GetChannelInput(texChannel);

                        channelInput.enabled = GUILayout.Toggle(channelInput.enabled, new GUIContent(" " + channels [i]), GUILayout.Width(60));

                        GUILayout.Label(">");

                        channelInput.output = (TextureChannel)EditorGUILayout.Popup((int)channelInput.output, channels, GUILayout.Width(80));

                        input.SetChannelInput(texChannel, channelInput);

                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndVertical();

                    input.texture = EditorGUILayout.ObjectField(input.texture, typeof(Texture2D), false, GUILayout.Width(90), GUILayout.Height(80)) as Texture2D;

                    GUILayout.EndHorizontal();
                }
            }
        }