private SetWrapModeNoDirty ( |
||
tex | ||
mode | TextureWrapMode | |
return | void |
public override void OnInspectorGUI() { EditorGUILayout.PropertyField(this.m_IsReadable, IHVImageFormatImporterInspector.Styles.readWrite, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_sRGBTexture, IHVImageFormatImporterInspector.Styles.sRGBTexture, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); this.TextureSettingsGUI(); if (EditorGUI.EndChangeCheck()) { UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { AssetImporter assetImporter = (AssetImporter)targets[i]; Texture tex = AssetDatabase.LoadMainAssetAtPath(assetImporter.assetPath) as Texture; if (this.m_FilterMode.intValue != -1) { TextureUtil.SetFilterModeNoDirty(tex, (FilterMode)this.m_FilterMode.intValue); } if ((this.m_WrapU.intValue != -1 || this.m_WrapV.intValue != -1 || this.m_WrapW.intValue != -1) && !this.m_WrapU.hasMultipleDifferentValues && !this.m_WrapV.hasMultipleDifferentValues && !this.m_WrapW.hasMultipleDifferentValues) { TextureUtil.SetWrapModeNoDirty(tex, (TextureWrapMode)this.m_WrapU.intValue, (TextureWrapMode)this.m_WrapV.intValue, (TextureWrapMode)this.m_WrapW.intValue); } } SceneView.RepaintAll(); } GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); base.ApplyRevertGUI(); GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { EditorGUILayout.PropertyField(m_IsReadable, Styles.readWrite); EditorGUILayout.PropertyField(m_sRGBTexture, Styles.sRGBTexture); EditorGUI.BeginChangeCheck(); TextureSettingsGUI(); if (EditorGUI.EndChangeCheck()) { // copy pasted from TextureImporterInspector.TextureSettingsGUI() foreach (AssetImporter importer in targets) { Texture tex = AssetDatabase.LoadMainAssetAtPath(importer.assetPath) as Texture; if (m_FilterMode.intValue != -1) { TextureUtil.SetFilterModeNoDirty(tex, (FilterMode)m_FilterMode.intValue); } if ((m_WrapU.intValue != -1 || m_WrapV.intValue != -1 || m_WrapW.intValue != -1) && !m_WrapU.hasMultipleDifferentValues && !m_WrapV.hasMultipleDifferentValues && !m_WrapW.hasMultipleDifferentValues) { TextureUtil.SetWrapModeNoDirty(tex, (TextureWrapMode)m_WrapU.intValue, (TextureWrapMode)m_WrapV.intValue, (TextureWrapMode)m_WrapW.intValue); } } SceneView.RepaintAll(); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); ApplyRevertGUI(); GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { this.IsReadableGUI(); EditorGUI.BeginChangeCheck(); this.TextureSettingsGUI(); if (EditorGUI.EndChangeCheck()) { UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { AssetImporter assetImporter = (AssetImporter)targets[i]; Texture tex = AssetDatabase.LoadMainAssetAtPath(assetImporter.assetPath) as Texture; if (this.m_FilterMode.intValue != -1) { TextureUtil.SetFilterModeNoDirty(tex, (FilterMode)this.m_FilterMode.intValue); } if (this.m_WrapMode.intValue != -1) { TextureUtil.SetWrapModeNoDirty(tex, (TextureWrapMode)this.m_WrapMode.intValue); } } SceneView.RepaintAll(); } GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); base.ApplyRevertGUI(); GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(m_IsReadable, Styles.readWrite); EditorGUILayout.PropertyField(m_sRGBTexture, Styles.sRGBTexture); EditorGUI.BeginChangeCheck(); TextureSettingsGUI(); if (EditorGUI.EndChangeCheck()) { // copy pasted from TextureImporterInspector.TextureSettingsGUI() foreach (AssetImporter importer in targets) { Texture tex = AssetDatabase.LoadMainAssetAtPath(importer.assetPath) as Texture; if (tex != null) { if (m_FilterMode.intValue != -1) { TextureUtil.SetFilterModeNoDirty(tex, (FilterMode)m_FilterMode.intValue); } if ((m_WrapU.intValue != -1 || m_WrapV.intValue != -1 || m_WrapW.intValue != -1) && !m_WrapU.hasMultipleDifferentValues && !m_WrapV.hasMultipleDifferentValues && !m_WrapW.hasMultipleDifferentValues) { TextureUtil.SetWrapModeNoDirty(tex, (TextureWrapMode)m_WrapU.intValue, (TextureWrapMode)m_WrapV.intValue, (TextureWrapMode)m_WrapW.intValue); } } } SceneView.RepaintAll(); } EditorGUILayout.PropertyField(m_StreamingMipmaps, Styles.streamingMipmaps); if (m_StreamingMipmaps.boolValue && !m_StreamingMipmaps.hasMultipleDifferentValues) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_StreamingMipmapsPriority, Styles.streamingMipmapsPriority); EditorGUI.indentLevel--; } serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); }
// wrap/filter/aniso editors will change serialized object // but in case of textures we need an extra step to ApplySettings (so rendering uses new values) // alas we cant have good things: it will be PITA to make sure we always call that after applying changes to serialized object // meaning that we need to work without relying on it, hence we do similar to TextureImporter: // use TextureUtil methods to update texture settings from current values of serialized property // another possibility would be to do it separately for wrap/filter/aniso // alas for wrapmode i dont see how it can be done clearly and leaving it out seems a bit weird protected void ApplySettingsToTextures() { bool anisoDiffer = m_Aniso.hasMultipleDifferentValues, filterDiffer = m_FilterMode.hasMultipleDifferentValues; bool wrapDiffer = m_WrapU.hasMultipleDifferentValues || m_WrapV.hasMultipleDifferentValues || m_WrapW.hasMultipleDifferentValues; foreach (Texture tex in targets) { if (!anisoDiffer) { TextureUtil.SetAnisoLevelNoDirty(tex, m_Aniso.intValue); } if (!filterDiffer) { TextureUtil.SetFilterModeNoDirty(tex, (FilterMode)m_FilterMode.intValue); } if (!wrapDiffer) { TextureUtil.SetWrapModeNoDirty(tex, (TextureWrapMode)m_WrapU.intValue, (TextureWrapMode)m_WrapV.intValue, (TextureWrapMode)m_WrapW.intValue); } } }
// wrap/filter/aniso editors will change serialized object // but in case of textures we need an extra step to ApplySettings (so rendering uses new values) // alas we cant have good things: it will be PITA to make sure we always call that after applying changes to serialized object // meaning that we need to work without relying on it, hence we do similar to TextureImporter: // use TextureUtil methods to update texture settings from current values of serialized property // another possibility would be to do it separately for wrap/filter/aniso // alas for wrapmode i dont see how it can be done clearly and leaving it out seems a bit weird protected void ApplySettingsToTextures() { bool anisoDiffer = m_Aniso.hasMultipleDifferentValues, filterDiffer = m_FilterMode.hasMultipleDifferentValues; bool wrapDiffer = m_WrapU.hasMultipleDifferentValues || m_WrapV.hasMultipleDifferentValues || m_WrapW.hasMultipleDifferentValues; foreach (Texture tex in targets) { if (m_Aniso.intValue != -1 && !anisoDiffer) { TextureUtil.SetAnisoLevelNoDirty(tex, m_Aniso.intValue); } if (m_FilterMode.intValue != -1 && !filterDiffer) { TextureUtil.SetFilterModeNoDirty(tex, (FilterMode)m_FilterMode.intValue); } // NB i am not sure if it is *possible* to have -1 in there and if it make sense to pass -1 to SetWrapModeNoDirty // NB but this is how TextureImporter checks things and who am i to argue if ((m_WrapU.intValue != -1 || m_WrapV.intValue != -1 || m_WrapW.intValue != -1) && !wrapDiffer) { TextureUtil.SetWrapModeNoDirty(tex, (TextureWrapMode)m_WrapU.intValue, (TextureWrapMode)m_WrapV.intValue, (TextureWrapMode)m_WrapW.intValue); } } }