new void OnEnable() { nguiEffect = (TextFxNGUI)target; animationManager = nguiEffect.AnimationManager; EditorApplication.update += UpdateManager; base.OnEnable(); }
static void ConvertToTextFX() { GameObject activeGO = Selection.activeGameObject; UILabel uLabelText = activeGO.GetComponent <UILabel> (); Vector3 cachedPosition = uLabelText.cachedTransform.localPosition; TextFxNGUI textfxNGUI = activeGO.GetComponent <TextFxNGUI> (); if (textfxNGUI != null) { return; } textfxNGUI = activeGO.AddComponent <TextFxNGUI>(); uLabelText.GetCloneOf <UILabel, TextFxNGUI> (ref textfxNGUI, new string[] { "mainTexture", "shader" }); DestroyImmediate(uLabelText); uLabelText.cachedTransform.localPosition = cachedPosition; Debug.Log(activeGO.name + "'s UILabel component converted into a TextFxNGUI component"); }
static public void AddLabel() { GameObject go = NGUIEditorTools.SelectedRoot(true); if (go != null) { #if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 Undo.RegisterSceneUndo("Add a Label"); #endif TextFxNGUI w = NGUITools.AddWidget <TextFxNGUI>(go); w.name = NEW_INSTANCE_NAME; w.ambigiousFont = NGUISettings.ambigiousFont; w.text = "New Label"; w.pivot = NGUISettings.pivot; w.width = 120; w.height = Mathf.Max(20, NGUISettings.GetInt("NGUI Font Height", 16)); w.fontStyle = NGUISettings.fontStyle; w.fontSize = NGUISettings.fontSize; w.applyGradient = true; w.gradientBottom = new Color(0.7f, 0.7f, 0.7f); w.AssumeNaturalSize(); // return w; if (w.bitmapFont == null && w.trueTypeFont == null) { w.trueTypeFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; } Selection.activeGameObject = w.gameObject; } else { Debug.Log("You must select a game object first."); } }