private static void TextureArrayItem() { Texture2DArrayData texture2DArray = CreateInstance <Texture2DArrayData> (); texture2DArray.Initialize(Selection.GetFiltered <Texture2D> (SelectionMode.TopLevel)); string assetPath = AssetDatabase.GetAssetPath(texture2DArray.m_textures [0]); assetPath = assetPath.Remove(assetPath.LastIndexOf('/')) + "/Texture2DArray.asset"; AssetDatabase.CreateAsset(texture2DArray, assetPath); AssetDatabase.SaveAssets(); Selection.activeObject = texture2DArray; texture2DArray.Rebuild(); }
/// <summary> /// Draw TextureArrayData inspector. /// </summary> public override void OnInspectorGUI() { m_arrayData.Validate(); serializedObject.Update(); SerializedProperty isAutomatic = serializedObject.FindProperty("m_isAutomatic"); EditorGUILayout.PropertyField(isAutomatic, new GUIContent("Automatic")); GUI.enabled = !isAutomatic.boolValue; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_width")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_height")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_format")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_aniso")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_wrapModeU")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_wrapModeV")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_mipMapCount")); if (EditorGUI.EndChangeCheck()) { m_isModified = true; } GUI.enabled = true; GUILayout.Space(16); m_list.DoLayoutList(); serializedObject.ApplyModifiedProperties(); if (m_isModified) { m_arrayData.Rebuild(); m_isModified = false; } }