void Awake() { play = TPackManager.getAtlas(Atlases.EXAMPLE).getPngTexture("play"); //Warning to Get Texture2D from atlas, should remain the same size which was generated, //that's why we using another atlas here unityTexture = TPackManager.getAtlas(Atlases.EXAMPLE2).getUnityTexture("play"); }
void OnGUI() { play.draw(new Rect(0, 0, play.width * 0.5f, play.height * 0.5f)); play.draw(new Rect(0, 75, play.width, play.height)); GUI.DrawTexture(new Rect(0, 225, unityTexture.width, unityTexture.height), unityTexture); TPAtlasTexture tex = TPackManager.getAtlas(Atlases.EXAMPLE).getPngTexture("f_share"); tex.draw(new Rect(200, 0, 122, 42)); TPackManager.getAtlas(Atlases.EXAMPLE).draw(new Rect(200, 100, 122, 42), "t_share.png"); }
void Awake() { anim = TPGUIAnimation.Create(); Scaledanim = TPGUIAnimation.Create(); for (int i = 1; i < 7; i++) { TPAtlasTexture frame = TPackManager.getAtlas(Atlases.EXAMPLE).getPngTexture("fireball_000" + i.ToString()); anim.addFrame(frame); Scaledanim.addFrame(frame); } anim.pos = new Vector2(200, 200); anim.loop = true; anim.fps = 25; anim.Play(); Scaledanim.pos = new Vector2(300, 200); Scaledanim.loop = true; Scaledanim.fps = 25; Scaledanim.scale = 0.5f; Scaledanim.Play(); }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- //-------------------------------------- // GET/SET //-------------------------------------- //-------------------------------------- // EVENTS //-------------------------------------- private void OnLoadProgress() { loadProgress++; if (loadProgress == 2) { //image and atlas data downloaded //registration new atlas TPackManager.load(atlasData, atlasImage, "NewDownloadedAtlas"); //applying downloaded image to material atlasObject.GetComponent <Renderer>().material.mainTexture = atlasImage; //creating mesh texture component TPMeshTextureNoHelperEx meshTexture = atlasObject.AddComponent <TPMeshTextureNoHelperEx> (); //applying properties and updating view meshTexture.atlas = "NewDownloadedAtlas"; meshTexture.texture = "play"; meshTexture.UpdateView(); } }
private void renderAtlasPreview() { string[] atlasesNames = TPAssetPostprocessor.atlasesNames; if (atlasesNames.Length == 0) { return; } #if UNITY_4_3 #else EditorGUIUtility.LookLikeInspector(); #endif GUILayout.BeginHorizontal(TexturePackerStyles.toolBarBoxStyle); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); if (atlasIndex == -1) { int i = 0; string n = TPEditorData.selectedAtlasName; foreach (string atName in atlasesNames) { if (atName.Equals(n)) { atlasIndex = i; break; } i++; } if (atlasIndex == -1) { atlasIndex = 0; } } atlasIndex = EditorGUI.Popup( new Rect(-10, 0, TexturePackerStyles.ATLAS_POPUP_WIDTH, 20), "", atlasIndex, atlasesNames, TexturePackerStyles.toolBarDropDwonStyle); if (EditorGUI.EndChangeCheck()) { images.Clear(); selection.Clear(); TPEditorData.selectedAtlasName = atlasesNames [atlasIndex]; } GUIStyle btnStyle = EditorStyles.toolbarButton; if (GUILayout.Button("Refresh", btnStyle)) { TPackManager.clear(); TPAssetPostprocessor.UpdateAtlasesInfromation(); } if (GUILayout.Button(addButtonText, btnStyle)) { addSelectedFrameToAnimation(); } if (TPEditorData.isExtensionsEnabled) { btnStyle = TexturePackerStyles.toobarEnabledButton; } if (GUILayout.Button("Extensions", btnStyle)) { TPEditorData.isExtensionsEnabled = !TPEditorData.isExtensionsEnabled; } search = GUILayout.TextField(search, GUI.skin.FindStyle("ToolbarSeachTextField"), TexturePackerStyles.FixedWidth(200f)); if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) { // Remove focus if cleared search = ""; GUI.FocusControl(null); } GUILayout.EndHorizontal(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(editor.position.width), GUILayout.Height(editor.position.height - 17f)); GUILayout.Box("", GUIStyle.none, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(_maxY) }); _maxY = 0f; TextureNodeRenderer.calculateVars(editor.position.width - 10f); currentAtlas = getAtlas(atlasesNames[atlasIndex]); Rect r; int index = 0; images.Clear(); foreach (string name in currentAtlas.frameNames) { if (search != string.Empty) { if (!name.ToLower().Contains(search.ToLower())) { continue; } } r = TextureNodeRenderer.RenderNode(index, currentAtlas, name); rememberImageRect(name, r); setNodeY(r.y + r.height * 1.5f); index++; } EditorGUILayout.EndScrollView(); }
//-------------------------------------- // GET / SET //-------------------------------------- private TPAtlas getAtlas(string atlasName) { string path = TPAtlasesData.getAtlasPath(atlasName); return(TPackManager.getAtlas(path)); }
//-------------------------------------- // EVENTS //-------------------------------------- //-------------------------------------- // PRIVATE METHODS //-------------------------------------- private TPAtlasTexture GetAtlasTExture(int index) { TPFameInfo frame = frames[index]; return(TPackManager.getAtlas(frame.atlasPath).getTexture(frame.textureName)); }