public static void LoadIcon(string bundleName, NGUITexture _texture) { if (_texture != null) { _texture.mainTexture = Resources.Load(bundleName) as Texture; } }
/// <summary> /// UI Texture doesn't do anything other than creating the widget. /// </summary> void CreateSimpleTexture(GameObject go) { if (ShouldCreate(go, true)) { NGUITexture tex = NGUITools.AddWidget <NGUITexture>(go); Selection.activeGameObject = tex.gameObject; } }
override protected bool DrawProperties() { mTex = mWidget as NGUITexture; if (!mTex.hasDynamicMaterial && (mTex.material != null || mTex.mainTexture == null)) { Material mat = EditorGUILayout.ObjectField("Material", mTex.material, typeof(Material), false) as Material; if (mTex.material != mat) { NGUIEditorTools.RegisterUndo("Material Selection", mTex); mTex.material = mat; } } if (mTex.material == null || mTex.hasDynamicMaterial) { Shader shader = EditorGUILayout.ObjectField("Shader", mTex.shader, typeof(Shader), false) as Shader; if (mTex.shader != shader) { NGUIEditorTools.RegisterUndo("Shader Selection", mTex); mTex.shader = shader; } Texture tex = EditorGUILayout.ObjectField("Texture", mTex.mainTexture, typeof(Texture), false) as Texture; if (mTex.mainTexture != tex) { NGUIEditorTools.RegisterUndo("Texture Selection", mTex); mTex.mainTexture = tex; } } if (mTex.mainTexture != null) { Rect rect = EditorGUILayout.RectField("UV Rectangle", mTex.uvRect); if (rect != mTex.uvRect) { NGUIEditorTools.RegisterUndo("UV Rectangle Change", mTex); mTex.uvRect = rect; } } return(mWidget.material != null); }
protected override bool DrawProperties() { mTex = mWidget as NGUITexture; if (!mTex.hasDynamicMaterial && (mTex.material != null || mTex.mainTexture == null)) { Material mat = EditorGUILayout.ObjectField("Material", mTex.material, typeof(Material), false) as Material; if (mTex.material != mat) { NGUIEditorTools.RegisterUndo("Material Selection", mTex); mTex.material = mat; } } if (mTex.material == null || mTex.hasDynamicMaterial) { Shader shader = EditorGUILayout.ObjectField("Shader", mTex.shader, typeof(Shader), false) as Shader; if (mTex.shader != shader) { NGUIEditorTools.RegisterUndo("Shader Selection", mTex); mTex.shader = shader; } Texture tex = EditorGUILayout.ObjectField("Texture", mTex.mainTexture, typeof(Texture), false) as Texture; if (mTex.mainTexture != tex) { NGUIEditorTools.RegisterUndo("Texture Selection", mTex); mTex.mainTexture = tex; } } if (mTex.mainTexture != null) { Rect rect = EditorGUILayout.RectField("UV Rectangle", mTex.uvRect); if (rect != mTex.uvRect) { NGUIEditorTools.RegisterUndo("UV Rectangle Change", mTex); mTex.uvRect = rect; } } return (mWidget.material != null); }
static public void AddTexture() { GameObject go = NGUIEditorTools.SelectedRoot(true); if (go != null) { Undo.RegisterSceneUndo("Add a Texture"); NGUITexture tex = NGUITools.AddWidget <NGUITexture>(go); tex.name = "Texture"; tex.pivot = NGUISettings.pivot; tex.cachedTransform.localScale = new Vector3(100f, 100f, 1f); Selection.activeGameObject = tex.gameObject; } else { Debug.Log("You must select a game object first."); } }
public static void LoadIcon(string bundleName, NGUITexture _texture) { if (_texture != null) _texture.mainTexture = Resources.Load(bundleName) as Texture; }