Beispiel #1
0
    public bool Initialize()
    {
        if (this.IsInitialized)
        {
            return(false);
        }

        this.IsInitialized = true;
        this.material.SetTexture(this.parameter, Texture2DArrayGenerator.Generate(this.textures, this.format));
        this.material.SetInt(this.parameter + "Length", this.textures.Length);

        return(true);
    }
Beispiel #2
0
    protected void OnGUI()
    {
        GUIStyle marginStyle = GUI.skin.label;

        marginStyle.wordWrap = true;
        marginStyle.margin   = new RectOffset(5, 5, 5, 5);

        if (GUILayout.Button("Generate"))
        {
            string path = AssetCreationHelper.CreateAssetInCurrentDirectory
                              (Texture2DArrayGenerator.Generate(this.textures), this.fileName);

            ShowNotification(new GUIContent("SUCCESS : " + path));
        }

        this.fileName = EditorGUILayout.TextField("File Name", this.fileName);

        SerializedObject scriptableObject = new SerializedObject(this);

        EditorGUILayout.PropertyField(scriptableObject.FindProperty("textures"), true);
        scriptableObject.ApplyModifiedProperties();
    }
    private void OnGUI()
    {
        var marginStyle = GUI.skin.label;

        marginStyle.wordWrap = true;
        marginStyle.margin   = new RectOffset(5, 5, 5, 5);

        if (GUILayout.Button("Generate"))
        {
            var path = AssetCreationHelper.CreateAssetInCurrentDirectory
                           (Texture2DArrayGenerator.Generate(textures, format, mipChain), fileName);

            ShowNotification(new GUIContent("SUCCESS : " + path));
        }

        fileName = EditorGUILayout.TextField("File Name", fileName);
        format   = (TextureFormat)EditorGUILayout.EnumPopup("Format", format);
        mipChain = EditorGUILayout.Toggle("MipChain", mipChain);

        var serializedObject = new SerializedObject(this);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("textures"), true);
        serializedObject.ApplyModifiedProperties();
    }
Beispiel #4
0
 protected virtual void Awake()
 {
     this.instancingMaterial.SetTexture("_Textures", Texture2DArrayGenerator.Generate(this.textures));
 }
Beispiel #5
0
    private void OnGUI()
    {
        GUIStyle marginStyle = GUI.skin.label;

        marginStyle.wordWrap = true;
        marginStyle.margin   = new RectOffset(5, 5, 5, 5);

        filename = EditorGUILayout.TextField(filename);
        format   = (TextureFormat)EditorGUILayout.EnumPopup("Format", format);
        int count = EditorGUILayout.IntField("Count", textures.Length);

        if (count != textures.Length)
        {
            var newTextures = new Texture2D[count];
            int copyCount   = Math.Min(count, textures.Length);
            for (int i = 0; i < copyCount; i++)
            {
                newTextures[i] = textures[i];
            }

            textures  = newTextures;
            scrollPos = Vector2.zero;
        }

        scrollPos = GUILayout.BeginScrollView(scrollPos);
        for (int i = 0; i < textures.Length; i++)
        {
            textures[i] = TextureField("Texture " + i, textures[i]);
        }

        GUILayout.EndScrollView();

        if (GUILayout.Button("Generate"))
        {
            bool allValid = true;
            foreach (var texture in textures)
            {
                if (texture == null)
                {
                    allValid = false;
                    break;
                }
            }

            if (textures.Length == 0)
            {
                allValid = false;
            }

            if (allValid)
            {
                var path = "Assets/" + filename + ".asset";

                Debug.Log(textures.ToString());
                var texture = Texture2DArrayGenerator.Generate(textures, format);
                if (texture != null)
                {
                    AssetDatabase.CreateAsset(texture, path);
                    ShowNotification(new GUIContent("Saved to: " + path));
                }
                else
                {
                    ShowNotification(new GUIContent("Failed to create array. Source textures have different size."));
                }
            }
        }
    }
Beispiel #6
0
 private void Start()
 {
     Texture2DArrayGenerator.Generate(textures, TextureFormat.RGB24, true);
 }