protected override bool ShouldDrawProperties() { if (target == null) { return(false); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); if (sp != null) { NGUISettings.texture = sp.objectReferenceValue as Texture; } if (mTex != null && (mTex.material == null || serializedObject.isEditingMultipleObjects)) { NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader"); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); EditorGUI.EndDisabledGroup(); return(true); }
protected override bool ShouldDrawProperties() { if (target == null) { return(false); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); SerializedProperty sp2 = NGUIEditorTools.DrawProperty("PathInUiFolder", serializedObject, "mOutPath"); if (sp2.stringValue != startPath) { startPath = sp2.stringValue; if (startPath != "") { mTex.mainTexture = UIHelper.getTexture2D("Assets/essential/texture/ui/" + startPath + ".png"); } Debug.Log("force delay read"); } NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); if (sp != null) { NGUISettings.texture = sp.objectReferenceValue as Texture; } if (mTex != null && (mTex.material == null || serializedObject.isEditingMultipleObjects)) { NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader"); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); sp = serializedObject.FindProperty("mFixedAspect"); bool before = sp.boolValue; NGUIEditorTools.DrawProperty("Fixed Aspect", sp); if (sp.boolValue != before) { (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f); } if (sp.boolValue) { EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info); } EditorGUI.EndDisabledGroup(); return(true); }
protected override bool ShouldDrawProperties() { if (target == null) { return(false); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); if (sp != null) { NGUISettings.texture = sp.objectReferenceValue as Texture; } sp = NGUIEditorTools.DrawProperty("Alpha Texture", serializedObject, "mAlphaTexture"); if (sp != null) { NGUISettings.alphaTexture = sp.objectReferenceValue as Texture; } NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); if (mTex != null && (mTex.material == null || serializedObject.isEditingMultipleObjects)) { NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader"); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); sp = serializedObject.FindProperty("mFixedAspect"); bool before = sp.boolValue; NGUIEditorTools.DrawProperty("Fixed Aspect", sp); if (sp.boolValue != before) { (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f); } if (sp.boolValue) { EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info); } EditorGUI.EndDisabledGroup(); return(true); }
protected override bool ShouldDrawProperties() { if (target == null) { return(false); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); EditorGUILayout.BeginHorizontal(); SerializedProperty texPathSP = serializedObject.FindProperty("mTexturePath"); if (sp != null && sp.objectReferenceValue != null) { string path = AssetDatabase.GetAssetPath(sp.objectReferenceValue); if (texPathSP.stringValue != path) { texPathSP.stringValue = path; mTex.cacheTexture = sp.objectReferenceValue as Texture; mTex.baseTexture = null; } } EditorGUILayout.TextField("Path", texPathSP.stringValue); if (GUILayout.Button("GO", GUILayout.Width(30)) && mTex.cacheTexture != null) { Selection.activeObject = mTex.cacheTexture; } EditorGUILayout.EndHorizontal(); NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); if (sp != null) { NGUISettings.texture = sp.objectReferenceValue as Texture; } if (mTex != null && (mTex.material == null || serializedObject.isEditingMultipleObjects)) { NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader"); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); sp = serializedObject.FindProperty("mFixedAspect"); bool before = sp.boolValue; NGUIEditorTools.DrawProperty("Fixed Aspect", sp); if (sp.boolValue != before) { (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f); } if (sp.boolValue) { EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info); } EditorGUI.EndDisabledGroup(); return(true); }
protected override bool ShouldDrawProperties() { if (target == null) { return(false); } if (Application.isPlaying == false && NGUIEditorTools.DrawHeader("Tex to Spr")) { NGUIEditorTools.BeginContents(); GUILayout.BeginHorizontal(); if (NGUIEditorTools.DrawPrefixButton("Atlas")) { ComponentSelector.Show <UIAtlas>(OnSelectAtlas); } UIAtlas curAtlas = NGUISettings.atlas; if (curAtlas != null) { GUILayout.Label(curAtlas.name, "HelpBox", GUILayout.Height(18f)); } else { GUILayout.Label("No Atlas", "HelpBox", GUILayout.Height(18f)); } GUILayout.FlexibleSpace(); if (GUILayout.Button("ToS", GUILayout.Width(40f))) { if (curAtlas == null) { CreateOwnAtlas(); curAtlas = NGUISettings.atlas; } List <UIAtlasMaker.SpriteEntry> entries = UIAtlasMaker.CreateSprites(new List <Texture>() { mTex.mainTexture }); UIAtlasMaker.ExtractSprites(curAtlas, entries); UIAtlasMaker.UpdateAtlas(curAtlas, entries); UISprite sprite = mTex.gameObject.AddComponent <UISprite>(); sprite.atlas = curAtlas; sprite.spriteName = mTex.mainTexture.name; sprite.type = mTex.type; UISpriteData data = sprite.GetAtlasSprite(); data.SetBorder((int)mTex.border.w, (int)mTex.border.y, (int)mTex.border.x, (int)mTex.border.z); sprite.depth = mTex.depth; sprite.width = mTex.width; sprite.height = mTex.height; UITexture.DestroyImmediate(mTex); EditorGUIUtility.ExitGUI(); return(false); } GUILayout.EndHorizontal(); NGUIEditorTools.EndContents(); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); if (sp != null) { NGUISettings.texture = sp.objectReferenceValue as Texture; } if (mTex != null && (mTex.material == null || serializedObject.isEditingMultipleObjects)) { NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader"); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); sp = serializedObject.FindProperty("mFixedAspect"); bool before = sp.boolValue; NGUIEditorTools.DrawProperty("Fixed Aspect", sp); if (sp.boolValue != before) { (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f); } if (sp.boolValue) { EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info); } EditorGUI.EndDisabledGroup(); return(true); }
protected override bool ShouldDrawProperties() { if (target == null) { return(false); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); if (sp != null) { var tex = sp.objectReferenceValue as Texture; mTex.mainTexture = tex; NGUISettings.texture = tex; } sp = NGUIEditorTools.DrawProperty("Mask Texture", serializedObject, "mMaskTexture"); if (sp != null) { mTex.maskTexture = sp.objectReferenceValue as Texture; } //NGUIEditorTools.DrawProperty("Material (Test)", serializedObject, "mMat"); sp = NGUIEditorTools.DrawProperty("Rebuild Material", serializedObject, "mRebuildMaterial"); bool rebuildMat = sp.boolValue; mTex.isRebuildMaterial = rebuildMat; if (!rebuildMat) { EditorGUILayout.HelpBox("If this flag is disabled, this component will share its material along with other duplicated or prefab instances.", MessageType.Info); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); sp = NGUIEditorTools.DrawProperty("Fix Mask UV", serializedObject, "mFixMaskUV"); bool fixMaskUV = sp.boolValue; mTex.fixMaskUV = fixMaskUV; if (!fixMaskUV) { EditorGUILayout.HelpBox("If this flag is disabled, the mask area will be affected by UV Rect settings.", MessageType.Info); } sp = serializedObject.FindProperty("mFixedAspect"); bool before = sp.boolValue; NGUIEditorTools.DrawProperty("Fixed Aspect", sp); if (sp.boolValue != before) { (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f); } if (sp.boolValue) { EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info); } EditorGUI.EndDisabledGroup(); return(true); }