public override void OnInspectorGUI() { if (GUILayout.Button("<b>SUB OBJECT SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { GUI.enabled = false; EditorGUILayout.PropertyField(fontAsset_prop); EditorGUILayout.PropertyField(spriteAsset_prop); GUI.enabled = true; } EditorGUILayout.Space(); if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { Material material = m_canvasRenderer.GetMaterial(); if (material != m_targetMaterial) { m_targetMaterial = material; Object.DestroyImmediate(m_materialEditor); } if (m_materialEditor == null) { m_materialEditor = Editor.CreateEditor(material); } m_materialEditor.DrawHeader(); m_materialEditor.OnInspectorGUI(); } }
public void OnEnable() { // Get the UI Skin and Styles for the various Editors TMP_UIStyleManager.GetUIStyles(); fontAsset_prop = serializedObject.FindProperty("m_fontAsset"); spriteAsset_prop = serializedObject.FindProperty("m_spriteAsset"); m_SubMeshComponent = target as TMP_SubMeshUI; //m_rectTransform = m_SubMeshComponent.rectTransform; m_canvasRenderer = m_SubMeshComponent.canvasRenderer; // Create new Material Editor if one does not exists if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { m_materialEditor = Editor.CreateEditor(m_canvasRenderer.GetMaterial()); m_targetMaterial = m_canvasRenderer.GetMaterial(); } }
public override void OnInspectorGUI() { // If a Custom Material Editor exists, we use it. if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { Material mat = m_canvasRenderer.GetMaterial(); //Debug.Log(mat + " " + m_targetMaterial); if (mat != m_targetMaterial) { // Destroy previous Material Instance //Debug.Log("New Material has been assigned."); m_targetMaterial = mat; DestroyImmediate(m_materialEditor); } if (m_materialEditor == null) { m_materialEditor = Editor.CreateEditor(mat); } m_materialEditor.DrawHeader(); m_materialEditor.OnInspectorGUI(); } }
// Update is called once per frame void Update() { // Check if the material exists because it never finds the material on the first frame or so... if (thisRenderer.GetMaterial() != null) { Vector2 offset = new Vector2(Mathf.Cos(Time.time * scrollSpeed), Mathf.Sin(Time.time * scrollSpeed)); thisRenderer.GetMaterial().SetTextureOffset("_MainTex", offset); } }
public void OnEnable() { TMP_UIStyleManager.GetUIStyles(); fontAsset_prop = base.serializedObject.FindProperty("m_fontAsset"); spriteAsset_prop = base.serializedObject.FindProperty("m_spriteAsset"); m_SubMeshComponent = (base.target as TMP_SubMeshUI); m_canvasRenderer = m_SubMeshComponent.canvasRenderer; if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { m_materialEditor = Editor.CreateEditor(m_canvasRenderer.GetMaterial()); m_targetMaterial = m_canvasRenderer.GetMaterial(); } }
public void Draw() { canvasRender.Clear(); canvasRender.SetMaterial(wallMaterial, null); canvasRender.GetMaterial().color = Color.white; canvasRender.SetVertices(vertlist); //Debug.Log("cout: " + list.Count); }
void MoveObject() { // offset is the amount by which the material will be translated per frame. // and then set the material offset of the main tex variable of the material assigned to the game object. // GetMaterial(n) where n is the interger index of the materials array assigned to the image script on the UI game object. offset -= (Time.deltaTime) / animSpeed; rend.GetMaterial().SetTextureOffset("_MainTex", new Vector2(0, -offset)); }
private Material GetSharedMaterial() { if (m_canvasRenderer == null) { m_canvasRenderer = base.GetComponent <CanvasRenderer>(); } return(m_canvasRenderer.GetMaterial()); }
public void OnMouseOver() { float red = renderer.GetMaterial().color.r; float green = renderer.GetMaterial().color.g; float blue = renderer.GetMaterial().color.b; renderer.GetMaterial().color += new Color(red, green, blue, .1f) * Time.deltaTime; Debug.Log("Over"); }
public override void OnInspectorGUI() { // FONT SETTINGS SECTION if (GUILayout.Button("<b>SUB OBJECT SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { GUI.enabled = false; EditorGUILayout.PropertyField(fontAsset_prop); EditorGUILayout.PropertyField(spriteAsset_prop); GUI.enabled = true; } EditorGUILayout.Space(); // If a Custom Material Editor exists, we use it. if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { Material mat = m_canvasRenderer.GetMaterial(); //Debug.Log(mat + " " + m_targetMaterial); if (mat != m_targetMaterial) { // Destroy previous Material Instance //Debug.Log("New Material has been assigned."); m_targetMaterial = mat; DestroyImmediate(m_materialEditor); } if (m_materialEditor == null) { m_materialEditor = Editor.CreateEditor(mat); } m_materialEditor.DrawHeader(); m_materialEditor.OnInspectorGUI(); } }
public void SetMaterialPropertyColor(string property, Color value, object context) { if (renderer && material != null) { Material tempMaterial = renderer.GetMaterial(); tempMaterial.SetColor(property, value); renderer.SetMaterial(tempMaterial, 0); } }
void UpdatePixels(float i) { print(i); rend.GetMaterial().SetFloat("_InvertAmount", i); foreach (CanvasRenderer childRend in gameObject.GetComponentsInChildren <CanvasRenderer>()) { childRend.GetMaterial().SetFloat("_InvertAmount", i); } }
private void SetZTestMode(CanvasRenderer r) { if (r.materialCount == 0) { return; } Material mat = new Material(r.GetMaterial(0)); mat.SetInt("unity_GUIZTestMode", (int)(enabled ? CompareFunction.Always : CompareFunction.LessEqual)); r.SetMaterial(mat, 0); }
private void UpdateMat() { Debug.Log("Updated material val"); CanvasRenderer image = GetComponent <CanvasRenderer>(); Material existingGlobalMat = image.GetMaterial(); Material updatedMaterial = new Material(existingGlobalMat); updatedMaterial.SetInt("unity_GUIZTestMode", (int)comparison); image.SetMaterial(updatedMaterial, 0); apply = false; }
IEnumerator LoadImage() { WWW www = new WWW(url2); yield return(www); //renderer.material.mainTexture = www.texture; //image script material = sprite- default material renderer = GetComponent <Renderer>(); canvRenderer = GetComponent <CanvasRenderer>(); canvRenderer.SetMaterial(canvRenderer.GetMaterial(), www.texture); //renderer.material.mainTexture = www.texture; }
IEnumerator FadeOut() { Debug.Log("Ejecutando shader"); for (float i = 0; i <= 1; i += 0.03f) { myRender.GetMaterial().SetFloat("_Burn_Value_1", i); yield return(new WaitForEndOfFrame()); } myRender.GetMaterial().SetFloat("_Burn_Value_1", 1); myRender.GetMaterial().SetFloat("_SpriteFade", 0f); Debug.Log("spritefade es" + myRender.GetMaterial().GetFloat("_SpriteFade")); }
public override void OnInspectorGUI() { GUI.enabled = false; EditorGUILayout.PropertyField(fontAsset_prop); EditorGUILayout.PropertyField(spriteAsset_prop); GUI.enabled = true; EditorGUILayout.Space(); // If a Custom Material Editor exists, we use it. if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { Material mat = m_canvasRenderer.GetMaterial(); //Debug.Log(mat + " " + m_targetMaterial); if (mat != m_targetMaterial) { // Destroy previous Material Instance //Debug.Log("New Material has been assigned."); m_targetMaterial = mat; DestroyImmediate(m_materialEditor); } if (m_materialEditor == null) { m_materialEditor = Editor.CreateEditor(mat); } m_materialEditor.DrawHeader(); m_materialEditor.OnInspectorGUI(); } }
public void UpdateState(Color color) { try { if (_canvasRenderer == null) { return; } var material = _canvasRenderer.GetMaterial(); material.SetColor(BaseColour, color); } catch (Exception e) { Debug.Log(e); } }
protected override void OnLateUpdate() { base.OnLateUpdate(); if (Application.isPlaying == true) { // キャレットが表示されなくなるバグ対策 if (_inputField != null && m_LE == null) { m_LE = _inputField.GetComponentInChildren <LayoutElement>(); if (m_LE != null) { CanvasRenderer tCR0 = m_LE.GetComponent <CanvasRenderer>(); CanvasRenderer tCR1 = _inputField.GetComponent <CanvasRenderer>(); if (tCR0 != null && tCR1 != null) { tCR0.SetMaterial(tCR1.GetMaterial(), 0); } } } } }
public static int GetMaterial(IntPtr l) { int result; try { int num = LuaDLL.lua_gettop(l); if (num == 1) { CanvasRenderer canvasRenderer = (CanvasRenderer)LuaObject.checkSelf(l); Material material = canvasRenderer.GetMaterial(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, material); result = 2; } else if (num == 2) { CanvasRenderer canvasRenderer2 = (CanvasRenderer)LuaObject.checkSelf(l); int index; LuaObject.checkType(l, 2, out index); Material material2 = canvasRenderer2.GetMaterial(index); LuaObject.pushValue(l, true); LuaObject.pushValue(l, material2); result = 2; } else { LuaObject.pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function GetMaterial to call"); result = 2; } } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
//Sets the arrows position and rotation. Also adjusts the scale of the arrow. private void UpdateArrow(Vector3 v3T) { canvasArrow.transform.position = new Vector3(transform.position.x, 100, transform.position.z); canvasArrow.transform.rotation = Quaternion.LookRotation(new Vector3(v3T.x, v3T.y, v3T.z)); canvasArrow.transform.rotation = Quaternion.Euler(new Vector3(270, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z - 90)); if (distance < MAX_ARROW_SCALE && distance > MIN_ARROW_SCALE) { arrowTail.sizeDelta = new Vector2(distance - ARROW_TAIL_MOUSE_OFFEST, arrowTail.rect.height); } else if (distance >= MAX_ARROW_SCALE) { arrowTail.sizeDelta = new Vector2(MAX_ARROW_SCALE - ARROW_TAIL_MOUSE_OFFEST, arrowTail.rect.height); distance = MAX_ARROW_SCALE; } else if (distance <= MIN_ARROW_SCALE) { arrowTail.sizeDelta = new Vector2(MIN_ARROW_SCALE - ARROW_TAIL_MOUSE_OFFEST, arrowTail.rect.height); distance = MIN_ARROW_SCALE; } arrowScalePercent = (distance - MIN_ARROW_SCALE) / (MAX_ARROW_SCALE - MIN_ARROW_SCALE); arrowTailRenderer.GetMaterial().SetFloat("_TexWidth", arrowScalePercent); }
public void OnEnable() { //Debug.Log("New Instance of TMPRO UGUI Editor with ID " + this.GetInstanceID()); // Initialize the Event Listener for Undo Events. Undo.undoRedoPerformed += OnUndoRedo; //Undo.postprocessModifications += OnUndoRedoEvent; text_prop = serializedObject.FindProperty("m_text"); fontAsset_prop = serializedObject.FindProperty("m_fontAsset"); fontSharedMaterial_prop = serializedObject.FindProperty("m_sharedMaterial"); //fontBaseMaterial_prop = serializedObject.FindProperty("m_baseMaterial"); isNewBaseMaterial_prop = serializedObject.FindProperty("m_isNewBaseMaterial"); fontStyle_prop = serializedObject.FindProperty("m_fontStyle"); fontSize_prop = serializedObject.FindProperty("m_fontSize"); fontSizeBase_prop = serializedObject.FindProperty("m_fontSizeBase"); autoSizing_prop = serializedObject.FindProperty("m_enableAutoSizing"); fontSizeMin_prop = serializedObject.FindProperty("m_fontSizeMin"); fontSizeMax_prop = serializedObject.FindProperty("m_fontSizeMax"); charSpacingMax_prop = serializedObject.FindProperty("m_charSpacingMax"); lineSpacingMax_prop = serializedObject.FindProperty("m_lineSpacingMax"); // Colors & Gradient fontColor_prop = serializedObject.FindProperty("m_fontColor"); enableVertexGradient_prop = serializedObject.FindProperty("m_enableVertexGradient"); fontColorGradient_prop = serializedObject.FindProperty("m_fontColorGradient"); overrideHtmlColor_prop = serializedObject.FindProperty("m_overrideHtmlColors"); characterSpacing_prop = serializedObject.FindProperty("m_characterSpacing"); lineSpacing_prop = serializedObject.FindProperty("m_lineSpacing"); paragraphSpacing_prop = serializedObject.FindProperty("m_paragraphSpacing"); textAlignment_prop = serializedObject.FindProperty("m_textAlignment"); enableWordWrapping_prop = serializedObject.FindProperty("m_enableWordWrapping"); wordWrappingRatios_prop = serializedObject.FindProperty("m_wordWrappingRatios"); textOverflowMode_prop = serializedObject.FindProperty("m_overflowMode"); horizontalMapping_prop = serializedObject.FindProperty("m_horizontalMapping"); verticalMapping_prop = serializedObject.FindProperty("m_verticalMapping"); uvOffset_prop = serializedObject.FindProperty("m_uvOffset"); uvLineOffset_prop = serializedObject.FindProperty("m_uvLineOffset"); enableKerning_prop = serializedObject.FindProperty("m_enableKerning"); //isOrthographic_prop = serializedObject.FindProperty("m_isOrthographic"); havePropertiesChanged_prop = serializedObject.FindProperty("havePropertiesChanged"); inputSource_prop = serializedObject.FindProperty("m_inputSource"); isInputPasingRequired_prop = serializedObject.FindProperty("isInputParsingRequired"); //isAffectingWordWrapping_prop = serializedObject.FindProperty("isAffectingWordWrapping"); enableExtraPadding_prop = serializedObject.FindProperty("m_enableExtraPadding"); isRichText_prop = serializedObject.FindProperty("m_isRichText"); checkPaddingRequired_prop = serializedObject.FindProperty("checkPaddingRequired"); margin_prop = serializedObject.FindProperty("m_margin"); //isMaskUpdateRequired_prop = serializedObject.FindProperty("isMaskUpdateRequired"); //mask_prop = serializedObject.FindProperty("m_mask"); maskOffset_prop = serializedObject.FindProperty("m_maskOffset"); //maskOffsetMode_prop = serializedObject.FindProperty("m_maskOffsetMode"); //maskSoftness_prop = serializedObject.FindProperty("m_maskSoftness"); //vertexOffset_prop = serializedObject.FindProperty("m_vertexOffset"); //sortingLayerID_prop = serializedObject.FindProperty("m_sortingLayerID"); //sortingOrder_prop = serializedObject.FindProperty("m_sortingOrder"); hasFontAssetChanged_prop = serializedObject.FindProperty("hasFontAssetChanged"); // Find to location of the TextMesh Pro Asset Folder (as users may have moved it) string tmproAssetFolderPath = TMPro_EditorUtility.GetAssetLocation(); if (EditorGUIUtility.isProSkin) { mySkin = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/TMPro_DarkSkin.guiskin", typeof(GUISkin)) as GUISkin; alignLeft = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignLeft.psd", typeof(Texture2D)) as Texture2D; alignCenter = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignCenter.psd", typeof(Texture2D)) as Texture2D; alignRight = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignRight.psd", typeof(Texture2D)) as Texture2D; alignJustified = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignJustified.psd", typeof(Texture2D)) as Texture2D; alignTop = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignTop.psd", typeof(Texture2D)) as Texture2D; alignMiddle = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignMiddle.psd", typeof(Texture2D)) as Texture2D; alignBottom = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignBottom.psd", typeof(Texture2D)) as Texture2D; } else { mySkin = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/TMPro_LightSkin.guiskin", typeof(GUISkin)) as GUISkin; alignLeft = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignLeft_Light.psd", typeof(Texture2D)) as Texture2D; alignCenter = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignCenter_Light.psd", typeof(Texture2D)) as Texture2D; alignRight = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignRight_Light.psd", typeof(Texture2D)) as Texture2D; alignJustified = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignJustified_Light.psd", typeof(Texture2D)) as Texture2D; alignTop = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignTop_Light.psd", typeof(Texture2D)) as Texture2D; alignMiddle = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignMiddle_Light.psd", typeof(Texture2D)) as Texture2D; alignBottom = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/Textures/btn_AlignBottom_Light.psd", typeof(Texture2D)) as Texture2D; } if (mySkin != null) { Section_Label = mySkin.FindStyle("Section Label"); //Group_Label = mySkin.FindStyle("Group Label"); textAreaBox = mySkin.FindStyle("Text Area Box (Editor)"); alignContent_A = new GUIContent[] { new GUIContent(alignLeft, "Left"), new GUIContent(alignCenter, "Center"), new GUIContent(alignRight, "Right"), new GUIContent(alignJustified, "Justified") }; alignContent_B = new GUIContent[] { new GUIContent(alignTop, "Top"), new GUIContent(alignMiddle, "Middle"), new GUIContent(alignBottom, "Bottom") }; } m_textMeshProScript = (TextMeshProUGUI)target; m_rectTransform = Selection.activeGameObject.GetComponent <RectTransform>(); m_uiRenderer = Selection.activeGameObject.GetComponent <CanvasRenderer>(); // Add a Material Component if one does not exists /* * m_materialComponent = Selection.activeGameObject.GetComponent<MaterialComponent> (); * if (m_materialComponent == null) * { * m_materialComponent = Selection.activeGameObject.AddComponent<MaterialComponent> (); * } */ // Create new Material Editor if one does not exists if (m_uiRenderer != null && m_uiRenderer.GetMaterial() != null) { m_materialEditor = Editor.CreateEditor(m_uiRenderer.GetMaterial()); m_targetMaterial = m_uiRenderer.GetMaterial(); //Debug.Log("Currently Assigned Material is " + m_targetMaterial + ". Font Material is " + m_textMeshProScript.fontSharedMaterial); } //m_updateManager = Camera.main.gameObject.GetComponent<TMPro_UpdateManager>(); }
public void UpdateMaterial() { UpdateMaterial(Target.GetMaterial()); }
public override void OnInspectorGUI() { // Make sure Multi selection only includes TMP Text objects. if (IsMixSelectionTypes()) { return; } serializedObject.Update(); //EditorGUIUtility.LookLikeControls(150, 30); Rect rect; float labelWidth = EditorGUIUtility.labelWidth = 130f; float fieldWidth = EditorGUIUtility.fieldWidth; // TEXT INPUT BOX SECTION if (GUILayout.Button("<b>TEXT INPUT BOX</b>" + (m_foldout.textInput ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.textInput = !m_foldout.textInput; } if (m_foldout.textInput) { EditorGUI.BeginChangeCheck(); text_prop.stringValue = EditorGUILayout.TextArea(text_prop.stringValue, TMP_UIStyleManager.TextAreaBoxEditor, GUILayout.Height(125), GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck()) { inputSource_prop.enumValueIndex = 0; isInputPasingRequired_prop.boolValue = true; //isCalculateSizeRequired_prop.boolValue = true; havePropertiesChanged = true; } } // FONT SETTINGS SECTION if (GUILayout.Button("<b>FONT SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { // FONT ASSET EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(fontAsset_prop); if (EditorGUI.EndChangeCheck()) { //Undo.RecordObject(m_textMeshProScript, "Material Change"); havePropertiesChanged = true; hasFontAssetChanged_prop.boolValue = true; } // FONT STYLE EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Font Style"); int styleValue = fontStyle_prop.intValue; int v1 = GUILayout.Toggle((styleValue & 1) == 1, "B", GUI.skin.button) ? 1 : 0; // Bold int v2 = GUILayout.Toggle((styleValue & 2) == 2, "I", GUI.skin.button) ? 2 : 0; // Italics int v3 = GUILayout.Toggle((styleValue & 4) == 4, "U", GUI.skin.button) ? 4 : 0; // Underline int v7 = GUILayout.Toggle((styleValue & 64) == 64, "S", GUI.skin.button) ? 64 : 0; // Strikethrough int v4 = GUILayout.Toggle((styleValue & 8) == 8, "ab", GUI.skin.button) ? 8 : 0; // Lowercase int v5 = GUILayout.Toggle((styleValue & 16) == 16, "AB", GUI.skin.button) ? 16 : 0; // Uppercase int v6 = GUILayout.Toggle((styleValue & 32) == 32, "SC", GUI.skin.button) ? 32 : 0; // Smallcaps EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { fontStyle_prop.intValue = v1 + v2 + v3 + v4 + v5 + v6 + v7; havePropertiesChanged = true; } // FACE VERTEX COLOR EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(fontColor_prop, new GUIContent("Color (Vertex)")); // VERTEX COLOR GRADIENT EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("Color Gradient"); EditorGUILayout.PropertyField(enableVertexGradient_prop, new GUIContent("Color Gradient"), GUILayout.MinWidth(140), GUILayout.MaxWidth(200)); EditorGUIUtility.labelWidth = 95; EditorGUILayout.PropertyField(overrideHtmlColor_prop, new GUIContent("Override Tags")); EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndHorizontal(); if (enableVertexGradient_prop.boolValue) { EditorGUILayout.PropertyField(fontColorGradient_prop.FindPropertyRelative("topLeft"), new GUIContent("Top Left")); EditorGUILayout.PropertyField(fontColorGradient_prop.FindPropertyRelative("topRight"), new GUIContent("Top Right")); EditorGUILayout.PropertyField(fontColorGradient_prop.FindPropertyRelative("bottomLeft"), new GUIContent("Bottom Left")); EditorGUILayout.PropertyField(fontColorGradient_prop.FindPropertyRelative("bottomRight"), new GUIContent("Bottom Right")); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } // FONT SIZE EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(fontSize_prop, new GUIContent("Font Size"), GUILayout.MinWidth(168), GUILayout.MaxWidth(200)); EditorGUIUtility.fieldWidth = fieldWidth; if (EditorGUI.EndChangeCheck()) { fontSizeBase_prop.floatValue = fontSize_prop.floatValue; havePropertiesChanged = true; //isAffectingWordWrapping_prop.boolValue = true; } EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 70; EditorGUILayout.PropertyField(autoSizing_prop, new GUIContent("Auto Size")); EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = labelWidth; if (EditorGUI.EndChangeCheck()) { if (autoSizing_prop.boolValue == false) { fontSize_prop.floatValue = fontSizeBase_prop.floatValue; } havePropertiesChanged = true; //isAffectingWordWrapping_prop.boolValue = true; } // Show auto sizing options if (autoSizing_prop.boolValue) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Auto Size Options"); EditorGUIUtility.labelWidth = 24; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(fontSizeMin_prop, new GUIContent("Min"), GUILayout.MinWidth(46)); if (EditorGUI.EndChangeCheck()) { fontSizeMin_prop.floatValue = Mathf.Min(fontSizeMin_prop.floatValue, fontSizeMax_prop.floatValue); havePropertiesChanged = true; } EditorGUIUtility.labelWidth = 27; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(fontSizeMax_prop, new GUIContent("Max"), GUILayout.MinWidth(49)); if (EditorGUI.EndChangeCheck()) { fontSizeMax_prop.floatValue = Mathf.Max(fontSizeMin_prop.floatValue, fontSizeMax_prop.floatValue); havePropertiesChanged = true; } EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 36; //EditorGUILayout.PropertyField(charSpacingMax_prop, new GUIContent("Char"), GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(charWidthMaxAdj_prop, new GUIContent("WD%"), GUILayout.MinWidth(58)); EditorGUIUtility.labelWidth = 28; EditorGUILayout.PropertyField(lineSpacingMax_prop, new GUIContent("Line"), GUILayout.MinWidth(50)); EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { charWidthMaxAdj_prop.floatValue = Mathf.Clamp(charWidthMaxAdj_prop.floatValue, 0, 50); //charSpacingMax_prop.floatValue = Mathf.Min(0, charSpacingMax_prop.floatValue); lineSpacingMax_prop.floatValue = Mathf.Min(0, lineSpacingMax_prop.floatValue); havePropertiesChanged = true; } } // CHARACTER, LINE & PARAGRAPH SPACING EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Spacing Options"); EditorGUIUtility.labelWidth = 30; EditorGUILayout.PropertyField(characterSpacing_prop, new GUIContent("Char"), GUILayout.MinWidth(50)); //, GUILayout.MaxWidth(100)); EditorGUILayout.PropertyField(lineSpacing_prop, new GUIContent("Line"), GUILayout.MinWidth(50)); //, GUILayout.MaxWidth(100)); EditorGUILayout.PropertyField(paragraphSpacing_prop, new GUIContent(" Par."), GUILayout.MinWidth(50)); //, GUILayout.MaxWidth(100)); EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; //isAffectingWordWrapping_prop.boolValue = true; } // TEXT ALIGNMENT EditorGUI.BeginChangeCheck(); rect = EditorGUILayout.GetControlRect(false, 17); GUIStyle btn = new GUIStyle(GUI.skin.button); btn.margin = new RectOffset(1, 1, 1, 1); btn.padding = new RectOffset(1, 1, 1, 0); selAlignGrid_A = textAlignment_prop.enumValueIndex & ~28; selAlignGrid_B = (textAlignment_prop.enumValueIndex & ~3) / 4; GUI.Label(new Rect(rect.x, rect.y, 100, rect.height), "Alignment"); float columnB = EditorGUIUtility.labelWidth + 15; selAlignGrid_A = GUI.SelectionGrid(new Rect(columnB, rect.y, 23 * 4, rect.height), selAlignGrid_A, TMP_UIStyleManager.alignContent_A, 4, btn); selAlignGrid_B = GUI.SelectionGrid(new Rect(columnB + 23 * 4 + 10, rect.y, 23 * 5, rect.height), selAlignGrid_B, TMP_UIStyleManager.alignContent_B, 5, btn); if (EditorGUI.EndChangeCheck()) { textAlignment_prop.enumValueIndex = selAlignGrid_A + selAlignGrid_B * 4; havePropertiesChanged = true; } // WRAPPING RATIOS shown if Justified mode is selected. EditorGUI.BeginChangeCheck(); if (textAlignment_prop.enumValueIndex == 3 || textAlignment_prop.enumValueIndex == 7 || textAlignment_prop.enumValueIndex == 11 || textAlignment_prop.enumValueIndex == 19) { DrawPropertySlider("Wrap Mix (W <-> C)", wordWrappingRatios_prop); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } // TEXT WRAPPING & OVERFLOW EditorGUI.BeginChangeCheck(); rect = EditorGUILayout.GetControlRect(false); EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 130, rect.height), new GUIContent("Wrapping & Overflow")); rect.width = (rect.width - 130) / 2f; rect.x += 130; int wrapSelection = EditorGUI.Popup(rect, enableWordWrapping_prop.boolValue ? 1 : 0, new string[] { "Disabled", "Enabled" }); if (EditorGUI.EndChangeCheck()) { enableWordWrapping_prop.boolValue = wrapSelection == 1 ? true : false; havePropertiesChanged = true; isInputPasingRequired_prop.boolValue = true; } // TEXT OVERFLOW EditorGUI.BeginChangeCheck(); if (textOverflowMode_prop.enumValueIndex != 5) { rect.x += rect.width + 5f; rect.width -= 5; EditorGUI.PropertyField(rect, textOverflowMode_prop, GUIContent.none); } else { rect.x += rect.width + 5f; rect.width /= 2; EditorGUI.PropertyField(rect, textOverflowMode_prop, GUIContent.none); rect.x += rect.width; rect.width -= 5; EditorGUI.PropertyField(rect, pageToDisplay_prop, GUIContent.none); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; isInputPasingRequired_prop.boolValue = true; } // TEXTURE MAPPING OPTIONS EditorGUI.BeginChangeCheck(); rect = EditorGUILayout.GetControlRect(false); EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 130, rect.height), new GUIContent("UV Mapping Options")); rect.width = (rect.width - 130) / 2f; rect.x += 130; EditorGUI.PropertyField(rect, horizontalMapping_prop, GUIContent.none); rect.x += rect.width + 5f; rect.width -= 5; EditorGUI.PropertyField(rect, verticalMapping_prop, GUIContent.none); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } // UV OPTIONS EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("UV Offset"); EditorGUILayout.PropertyField(uvOffset_prop, GUIContent.none, GUILayout.MinWidth(70f)); EditorGUIUtility.labelWidth = 30; EditorGUILayout.PropertyField(uvLineOffset_prop, new GUIContent("Line"), GUILayout.MinWidth(70f)); EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } // KERNING EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(enableKerning_prop, new GUIContent("Enable Kerning?")); if (EditorGUI.EndChangeCheck()) { //isAffectingWordWrapping_prop.boolValue = true; havePropertiesChanged = true; } // EXTRA PADDING EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(enableExtraPadding_prop, new GUIContent("Extra Padding?")); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; checkPaddingRequired_prop.boolValue = true; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("<b>EXTRA SETTINGS</b>" + (m_foldout.extraSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.extraSettings = !m_foldout.extraSettings; } if (m_foldout.extraSettings) { EditorGUI.indentLevel = 0; EditorGUI.BeginChangeCheck(); DrawMaginProperty(margin_prop, "Margins"); //DrawMaginProperty(maskOffset_prop, "Mask Offset"); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PropertyField(sortingLayerID_prop); //EditorGUILayout.PropertyField(sortingOrder_prop); //EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(isRichText_prop, new GUIContent("Enable Rich Text?")); EditorGUILayout.PropertyField(raycastTarget_prop, new GUIContent("Raycast Target?")); EditorGUILayout.EndHorizontal(); //EditorGUILayout.PropertyField(textRectangle_prop, true); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } // EditorGUI.BeginChangeCheck(); //EditorGUILayout.PropertyField(mask_prop); //EditorGUILayout.PropertyField(maskOffset_prop, true); //EditorGUILayout.PropertyField(maskSoftness_prop); //if (EditorGUI.EndChangeCheck()) //{ // isMaskUpdateRequired_prop.boolValue = true; // havePropertiesChanged = true; //} //EditorGUILayout.PropertyField(sortingLayerID_prop); //EditorGUILayout.PropertyField(sortingOrder_prop); // Mask Selection } EditorGUILayout.Space(); // If a Custom Material Editor exists, we use it. if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { Material mat = m_canvasRenderer.GetMaterial(); //Debug.Log(mat + " " + m_targetMaterial); if (mat != m_targetMaterial) { // Destroy previous Material Instance //Debug.Log("New Material has been assigned."); m_targetMaterial = mat; DestroyImmediate(m_materialEditor); } if (m_materialEditor == null) { m_materialEditor = Editor.CreateEditor(mat); } m_materialEditor.DrawHeader(); m_materialEditor.OnInspectorGUI(); } if (havePropertiesChanged) { //Debug.Log("Properties have changed."); havePropertiesChanged_prop.boolValue = true; havePropertiesChanged = false; EditorUtility.SetDirty(target); } serializedObject.ApplyModifiedProperties(); //m_targetMaterial = m_uiRenderer.GetMaterial(); }
private Vector3[] handlePoints = new Vector3[4]; // { new Vector3(-10, -10, 0), new Vector3(-10, 10, 0), new Vector3(10, 10, 0), new Vector3(10, -10, 0) }; //private float prev_lineLenght; //private bool m_isUndoSet; public void OnEnable() { //Debug.Log("New Instance of TMPRO UGUI Editor with ID " + this.GetInstanceID()); // Initialize the Event Listener for Undo Events. Undo.undoRedoPerformed += OnUndoRedo; //Undo.postprocessModifications += OnUndoRedoEvent; text_prop = serializedObject.FindProperty("m_text"); fontAsset_prop = serializedObject.FindProperty("m_fontAsset"); fontSharedMaterial_prop = serializedObject.FindProperty("m_sharedMaterial"); //fontBaseMaterial_prop = serializedObject.FindProperty("m_baseMaterial"); isNewBaseMaterial_prop = serializedObject.FindProperty("m_isNewBaseMaterial"); fontStyle_prop = serializedObject.FindProperty("m_fontStyle"); fontSize_prop = serializedObject.FindProperty("m_fontSize"); fontSizeBase_prop = serializedObject.FindProperty("m_fontSizeBase"); autoSizing_prop = serializedObject.FindProperty("m_enableAutoSizing"); fontSizeMin_prop = serializedObject.FindProperty("m_fontSizeMin"); fontSizeMax_prop = serializedObject.FindProperty("m_fontSizeMax"); //charSpacingMax_prop = serializedObject.FindProperty("m_charSpacingMax"); lineSpacingMax_prop = serializedObject.FindProperty("m_lineSpacingMax"); charWidthMaxAdj_prop = serializedObject.FindProperty("m_charWidthMaxAdj"); // Colors & Gradient fontColor_prop = serializedObject.FindProperty("m_fontColor"); enableVertexGradient_prop = serializedObject.FindProperty("m_enableVertexGradient"); fontColorGradient_prop = serializedObject.FindProperty("m_fontColorGradient"); overrideHtmlColor_prop = serializedObject.FindProperty("m_overrideHtmlColors"); characterSpacing_prop = serializedObject.FindProperty("m_characterSpacing"); lineSpacing_prop = serializedObject.FindProperty("m_lineSpacing"); paragraphSpacing_prop = serializedObject.FindProperty("m_paragraphSpacing"); textAlignment_prop = serializedObject.FindProperty("m_textAlignment"); enableWordWrapping_prop = serializedObject.FindProperty("m_enableWordWrapping"); wordWrappingRatios_prop = serializedObject.FindProperty("m_wordWrappingRatios"); textOverflowMode_prop = serializedObject.FindProperty("m_overflowMode"); pageToDisplay_prop = serializedObject.FindProperty("m_pageToDisplay"); horizontalMapping_prop = serializedObject.FindProperty("m_horizontalMapping"); verticalMapping_prop = serializedObject.FindProperty("m_verticalMapping"); uvOffset_prop = serializedObject.FindProperty("m_uvOffset"); uvLineOffset_prop = serializedObject.FindProperty("m_uvLineOffset"); enableKerning_prop = serializedObject.FindProperty("m_enableKerning"); //isOrthographic_prop = serializedObject.FindProperty("m_isOrthographic"); havePropertiesChanged_prop = serializedObject.FindProperty("m_havePropertiesChanged"); inputSource_prop = serializedObject.FindProperty("m_inputSource"); isInputPasingRequired_prop = serializedObject.FindProperty("m_isInputParsingRequired"); //isCalculateSizeRequired_prop = serializedObject.FindProperty("m_isCalculateSizeRequired"); enableExtraPadding_prop = serializedObject.FindProperty("m_enableExtraPadding"); isRichText_prop = serializedObject.FindProperty("m_isRichText"); checkPaddingRequired_prop = serializedObject.FindProperty("checkPaddingRequired"); raycastTarget_prop = serializedObject.FindProperty("m_RaycastTarget"); margin_prop = serializedObject.FindProperty("m_margin"); //isMaskUpdateRequired_prop = serializedObject.FindProperty("isMaskUpdateRequired"); //mask_prop = serializedObject.FindProperty("m_mask"); //maskOffset_prop= serializedObject.FindProperty("m_maskOffset"); //maskOffsetMode_prop = serializedObject.FindProperty("m_maskOffsetMode"); //maskSoftness_prop = serializedObject.FindProperty("m_maskSoftness"); //vertexOffset_prop = serializedObject.FindProperty("m_vertexOffset"); //sortingLayerID_prop = serializedObject.FindProperty("m_sortingLayerID"); //sortingOrder_prop = serializedObject.FindProperty("m_sortingOrder"); hasFontAssetChanged_prop = serializedObject.FindProperty("m_hasFontAssetChanged"); // Get the UI Skin and Styles for the various Editors TMP_UIStyleManager.GetUIStyles(); m_textComponent = target as TextMeshProUGUI; m_rectTransform = m_textComponent.rectTransform; m_canvasRenderer = m_textComponent.canvasRenderer; // Create new Material Editor if one does not exists if (m_canvasRenderer != null && m_canvasRenderer.GetMaterial() != null) { m_materialEditor = Editor.CreateEditor(m_canvasRenderer.GetMaterial()); m_targetMaterial = m_canvasRenderer.GetMaterial(); //UnityEditorInternal.InternalEditorUtility.SetIsInspectorExpanded(m_targetMaterial, true); //Debug.Log("Currently Assigned Material is " + m_targetMaterial + ". Font Material is " + m_textMeshProScript.fontSharedMaterial); } }
public ReplacementRendererCanvas(CanvasRenderer renderer) { this.renderer = renderer; material = renderer.GetMaterial(); }
// Update is called once per frame void Update() { float offset = Time.time * ScrollSpeed; rend?.GetMaterial()?.SetTextureOffset("_MainTex", new Vector2(0, offset)); }