本文整理汇总了C#中tk2dSpriteCollectionData类的典型用法代码示例。如果您正苦于以下问题:C# tk2dSpriteCollectionData类的具体用法?C# tk2dSpriteCollectionData怎么用?C# tk2dSpriteCollectionData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
tk2dSpriteCollectionData类属于命名空间,在下文中一共展示了tk2dSpriteCollectionData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DoDemoRuntimeSpriteCollection
private void DoDemoRuntimeSpriteCollection(tk2dSpriteCollectionSize spriteCollectionSize)
{
if (GUILayout.Button("Use Full Texture", new GUILayoutOption[0]))
{
this.DestroyData();
Rect region = new Rect(0f, 0f, (float) this.runtimeTexture.width, (float) this.runtimeTexture.height);
Vector2 anchor = new Vector2(region.width / 2f, region.height / 2f);
this.spriteInstance = tk2dSprite.CreateFromTexture(this.runtimeTexture, spriteCollectionSize, region, anchor, string.Empty).GetComponent<tk2dSprite>();
this.spriteCollectionInstance = this.spriteInstance.Collection;
}
if (GUILayout.Button("Extract Region)", new GUILayoutOption[0]))
{
this.DestroyData();
Rect rect2 = new Rect(79f, 243f, 215f, 200f);
Vector2 vector2 = new Vector2(rect2.width / 2f, rect2.height / 2f);
this.spriteInstance = tk2dSprite.CreateFromTexture(this.runtimeTexture, spriteCollectionSize, rect2, vector2, string.Empty).GetComponent<tk2dSprite>();
this.spriteCollectionInstance = this.spriteInstance.Collection;
}
if (GUILayout.Button("Extract multiple Sprites", new GUILayoutOption[0]))
{
this.DestroyData();
string[] names = new string[] { "Extracted region", "Another region", "Full sprite" };
Rect[] regions = new Rect[] { new Rect(79f, 243f, 215f, 200f), new Rect(256f, 0f, 64f, 64f), new Rect(0f, 0f, (float) this.runtimeTexture.width, (float) this.runtimeTexture.height) };
Vector2[] anchors = new Vector2[] { new Vector2(regions[0].width / 2f, regions[0].height / 2f), new Vector2(0f, regions[1].height), new Vector2(0f, regions[1].height) };
this.spriteCollectionInstance = tk2dSpriteCollectionData.CreateFromTexture(this.runtimeTexture, spriteCollectionSize, names, regions, anchors);
GameObject obj4 = new GameObject("sprite");
obj4.transform.localPosition = new Vector3(-1f, 0f, 0f);
this.spriteInstance = obj4.AddComponent<tk2dSprite>();
this.spriteInstance.SetSprite(this.spriteCollectionInstance, 0);
obj4 = new GameObject("sprite2");
obj4.transform.parent = this.spriteInstance.transform;
obj4.transform.localPosition = new Vector3(2f, 0f, 0f);
obj4.AddComponent<tk2dSprite>().SetSprite(this.spriteCollectionInstance, "Another region");
}
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:35,代码来源:tk2dDemoRuntimeSpriteController.cs
示例2: DoDemoTexturePacker
void DoDemoTexturePacker(tk2dSpriteCollectionSize spriteCollectionSize) {
if (GUILayout.Button("Import")) {
DestroyData();
// Create atlas
spriteCollectionInstance = tk2dSpriteCollectionData.CreateFromTexturePacker(spriteCollectionSize, texturePackerExportFile.text, texturePackerTexture );
GameObject go = new GameObject("sprite");
go.transform.localPosition = new Vector3(-1, 0, 0);
spriteInstance = go.AddComponent<tk2dSprite>();
spriteInstance.SetSprite(spriteCollectionInstance, "sun");
go = new GameObject("sprite2");
go.transform.parent = spriteInstance.transform;
go.transform.localPosition = new Vector3(2, 0, 0);
tk2dSprite sprite = go.AddComponent<tk2dSprite>();
sprite.SetSprite(spriteCollectionInstance, "2dtoolkit_logo");
go = new GameObject("sprite3");
go.transform.parent = spriteInstance.transform;
go.transform.localPosition = new Vector3(1, 1, 0);
sprite = go.AddComponent<tk2dSprite>();
sprite.SetSprite(spriteCollectionInstance, "button_up");
go = new GameObject("sprite4");
go.transform.parent = spriteInstance.transform;
go.transform.localPosition = new Vector3(1, -1, 0);
sprite = go.AddComponent<tk2dSprite>();
sprite.SetSprite(spriteCollectionInstance, "Rock");
}
}
开发者ID:Ahere,项目名称:UnityIsometric,代码行数:31,代码来源:tk2dDemoRuntimeSpriteController.cs
示例3: DoPickSprite
public static void DoPickSprite(tk2dSpriteCollectionData spriteCollection, int spriteId, string title, tk2dSpriteGuiUtility.SpriteChangedCallback callback, object callbackData)
{
tk2dSpritePickerPopup popup = EditorWindow.GetWindow(typeof(tk2dSpritePickerPopup), true, title, true) as tk2dSpritePickerPopup;
popup.InitForSpriteInCollection(spriteCollection, spriteId);
popup.callback = callback;
popup.callbackData = callbackData;
}
开发者ID:jpann,项目名称:MissileDefense,代码行数:7,代码来源:tk2dSpritePickerPopup.cs
示例4: TransientData
public TransientData( tk2dSpriteCollectionData data ) {
name = data.spriteCollectionName;
dataWeakRef = new System.WeakReference(data);
if (data.needMaterialInstance) {
createdMaterials = data.materialInsts;
createdTextures = data.textureInsts;
}
}
开发者ID:dfos1,项目名称:Gladiator-Arena,代码行数:8,代码来源:tk2dEditorSpriteDataUnloader.cs
示例5: DoDemoRuntimeSpriteCollection
void DoDemoRuntimeSpriteCollection(tk2dSpriteCollectionSize spriteCollectionSize) {
if (GUILayout.Button("Use Full Texture")) {
DestroyData();
// Create a sprite, using the entire texture as the sprite
Rect region = new Rect(0, 0, runtimeTexture.width, runtimeTexture.height);
Vector2 anchor = new Vector2(region.width / 2, region.height / 2);
GameObject go = tk2dSprite.CreateFromTexture(runtimeTexture, spriteCollectionSize, region, anchor);
spriteInstance = go.GetComponent<tk2dSprite>();
spriteCollectionInstance = spriteInstance.Collection;
}
if (GUILayout.Button("Extract Region)")) {
DestroyData();
// Create a sprite, using a region of the texture as the sprite
Rect region = new Rect(79, 243, 215, 200);
Vector2 anchor = new Vector2(region.width / 2, region.height / 2);
GameObject go = tk2dSprite.CreateFromTexture(runtimeTexture, spriteCollectionSize, region, anchor);
spriteInstance = go.GetComponent<tk2dSprite>();
spriteCollectionInstance = spriteInstance.Collection;
}
if (GUILayout.Button("Extract multiple Sprites")) {
DestroyData();
string[] names = new string[] {
"Extracted region",
"Another region",
"Full sprite",
};
Rect[] regions = new Rect[] {
new Rect(79, 243, 215, 200),
new Rect(256, 0, 64, 64),
new Rect(0, 0, runtimeTexture.width, runtimeTexture.height)
};
Vector2[] anchors = new Vector2[] {
new Vector2(regions[0].width / 2, regions[0].height / 2),
new Vector2(0, regions[1].height),
new Vector2(0, regions[1].height)
};
// Create a sprite collection with multiple sprites, using regions of the texture
spriteCollectionInstance = tk2dSpriteCollectionData.CreateFromTexture(runtimeTexture, spriteCollectionSize, names, regions, anchors);
GameObject go = new GameObject("sprite");
go.transform.localPosition = new Vector3(-1, 0, 0);
spriteInstance = go.AddComponent<tk2dSprite>();
spriteInstance.SetSprite(spriteCollectionInstance, 0);
go = new GameObject("sprite2");
go.transform.parent = spriteInstance.transform;
go.transform.localPosition = new Vector3(2, 0, 0);
tk2dSprite sprite = go.AddComponent<tk2dSprite>();
sprite.SetSprite(spriteCollectionInstance, "Another region");
}
}
开发者ID:Ahere,项目名称:UnityIsometric,代码行数:56,代码来源:tk2dDemoRuntimeSpriteController.cs
示例6: GetValidSpriteId
public static int GetValidSpriteId(tk2dSpriteCollectionData spriteCollection, int spriteId)
{
if (! (spriteId > 0 && spriteId < spriteCollection.spriteDefinitions.Length &&
spriteCollection.spriteDefinitions[spriteId].Valid) )
{
spriteId = spriteCollection.FirstValidDefinitionIndex;
if (spriteId == -1) spriteId = 0;
}
return spriteId;
}
开发者ID:Collegiennes,项目名称:Malisse,代码行数:10,代码来源:tk2dSpriteGuiUtility.cs
示例7: Processtk2dSpriteCollection
static void Processtk2dSpriteCollection(tk2dSpriteCollectionData spriteCollectionData)
{
if (spriteCollectionData != null)
{
BuildSpriteCollection(spriteCollectionData);
}
else
{
Logger.LogWarning("空的SpriteCollectionData在SpriteCollection");
}
}
开发者ID:s3chugo,项目名称:KEngine,代码行数:11,代码来源:CDepBuild_tk2dToolkit.cs
示例8: GetThumbnailTexture
public static Texture2D GetThumbnailTexture(tk2dSpriteCollectionData gen, int spriteId)
{
gen = gen.inst;
// If we already have a cached texture which matches the requirements, use that
foreach (var thumb in thumbnailCache)
{
if (thumb.cachedTexture != null && thumb.cachedSpriteCollection == gen && thumb.cachedSpriteId == spriteId)
return thumb.cachedTexture;
}
// Generate a texture
var param = gen.spriteDefinitions[spriteId];
if (param.sourceTextureGUID == null || param.sourceTextureGUID.Length != 0)
{
string assetPath = AssetDatabase.GUIDToAssetPath(param.sourceTextureGUID);
if (assetPath.Length > 0)
{
Texture2D tex = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)) as Texture2D;
if (tex != null)
{
SpriteThumbnailCache thumbnail = new SpriteThumbnailCache();
if (param.extractRegion)
{
Texture2D localTex = new Texture2D(param.regionW, param.regionH);
for (int y = 0; y < param.regionH; ++y)
{
for (int x = 0; x < param.regionW; ++x)
{
localTex.SetPixel(x, y, tex.GetPixel(param.regionX + x, param.regionY + y));
}
}
localTex.Apply();
thumbnail.cachedTexture = localTex;
thumbnail.needDestroy = true;
}
else
{
thumbnail.cachedTexture = tex;
}
// Prime cache for next time
thumbnail.cachedSpriteCollection = gen;
thumbnail.cachedSpriteId = spriteId;
thumbnailCache.Add(thumbnail);
return thumbnail.cachedTexture;
}
}
}
return null;
}
开发者ID:hyf042,项目名称:BakeryGirl-chess,代码行数:54,代码来源:tk2dSpriteThumbnailCache.cs
示例9: SpriteChangedCallbackImpl
// Sprite changed callback
// Create an instance - only ever use the instance through the property
void SpriteChangedCallbackImpl(tk2dSpriteCollectionData spriteCollection, int spriteId, object data) {
FrameGroup fg = data as FrameGroup;
// Ensure the user hasn't switched sprite collection
if (fg != null && frameGroups.IndexOf(fg) != -1) {
fg.spriteCollection = spriteCollection;
fg.spriteId = spriteId;
foreach (tk2dSpriteAnimationFrame frame in fg.frames) {
frame.spriteCollection = spriteCollection;
frame.spriteId = spriteId;
}
RecalculateFrames();
Repaint();
}
}
开发者ID:Eddikos,项目名称:public-access-1,代码行数:16,代码来源:tk2dSpriteAnimationClipEditor.cs
示例10: GetSpriteCollectionId
int GetSpriteCollectionId(tk2dSpriteCollectionData data)
{
if (indexLookup.ContainsKey(data))
return indexLookup[data];
var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(data));
for (int i = 0; i < spriteCollectionIndex.Length; ++i)
{
if (spriteCollectionIndex[i].spriteCollectionDataGUID == guid)
{
indexLookup[data] = i;
return i;
}
}
return 0; // default
}
开发者ID:stevesolomon,项目名称:MicroDungeonPrototype,代码行数:16,代码来源:tk2dSpriteAnimationEditor.cs
示例11: AddSpriteCollectionData
public void AddSpriteCollectionData(tk2dSpriteCollectionData sc)
{
#if UNITY_EDITOR
// prune list
GetSpriteCollectionIndex();
spriteCollectionIndex.RemoveAll(item => item == null);
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(sc));
bool existing = false;
tk2dSpriteCollectionIndex indexEntry = null;
foreach (var v in spriteCollectionIndex)
{
if (v.spriteCollectionDataGUID == guid)
{
indexEntry = v;
existing = true;
break;
}
}
if (indexEntry == null)
indexEntry = new tk2dSpriteCollectionIndex();
indexEntry.name = sc.spriteCollectionName;
indexEntry.spriteCollectionDataGUID = guid;
indexEntry.spriteCollectionGUID = sc.spriteCollectionGUID;
indexEntry.spriteNames = new string[sc.spriteDefinitions.Length];
indexEntry.spriteTextureGUIDs = new string[sc.spriteDefinitions.Length];
indexEntry.version = sc.version;
for (int i = 0; i < sc.spriteDefinitions.Length; ++i)
{
var s = sc.spriteDefinitions[i];
if (s != null)
{
indexEntry.spriteNames[i] = sc.spriteDefinitions[i].name;
indexEntry.spriteTextureGUIDs[i] = sc.spriteDefinitions[i].sourceTextureGUID;
}
else
{
indexEntry.spriteNames[i] = "";
indexEntry.spriteTextureGUIDs[i] = "";
}
}
if (!existing)
spriteCollectionIndex.Add(indexEntry);
#endif
}
开发者ID:nbolabs,项目名称:StreetNinja,代码行数:47,代码来源:tk2dIndex.cs
示例12: GetNamedSpriteInNewCollection
static int GetNamedSpriteInNewCollection(tk2dSpriteCollectionData spriteCollection, int spriteId, tk2dSpriteCollectionData newCollection) {
int newSpriteId = spriteId;
string oldSpriteName = (spriteCollection == null || spriteCollection.inst == null) ? "" : spriteCollection.inst.spriteDefinitions[spriteId].name;
int distance = -1;
for (int i = 0; i < newCollection.inst.spriteDefinitions.Length; ++i) {
if (newCollection.inst.spriteDefinitions[i].Valid) {
string newSpriteName = newCollection.inst.spriteDefinitions[i].name;
int tmpDistance = (newSpriteName == oldSpriteName) ? 0 :
Mathf.Abs ( (oldSpriteName.ToLower()).CompareTo(newSpriteName.ToLower ()));
if (distance == -1 || tmpDistance < distance) {
distance = tmpDistance;
newSpriteId = i;
}
}
}
return newSpriteId;
}
开发者ID:Eddikos,项目名称:public-access-1,代码行数:19,代码来源:tk2dSpriteGuiUtility.cs
示例13: DoDemoTexturePacker
private void DoDemoTexturePacker(tk2dSpriteCollectionSize spriteCollectionSize)
{
if (GUILayout.Button("Import", new GUILayoutOption[0]))
{
this.DestroyData();
this.spriteCollectionInstance = tk2dSpriteCollectionData.CreateFromTexturePacker(spriteCollectionSize, this.texturePackerExportFile.text, this.texturePackerTexture);
GameObject obj2 = new GameObject("sprite");
obj2.transform.localPosition = new Vector3(-1f, 0f, 0f);
this.spriteInstance = obj2.AddComponent<tk2dSprite>();
this.spriteInstance.SetSprite(this.spriteCollectionInstance, "sun");
obj2 = new GameObject("sprite2");
obj2.transform.parent = this.spriteInstance.transform;
obj2.transform.localPosition = new Vector3(2f, 0f, 0f);
obj2.AddComponent<tk2dSprite>().SetSprite(this.spriteCollectionInstance, "2dtoolkit_logo");
obj2 = new GameObject("sprite3");
obj2.transform.parent = this.spriteInstance.transform;
obj2.transform.localPosition = new Vector3(1f, 1f, 0f);
obj2.AddComponent<tk2dSprite>().SetSprite(this.spriteCollectionInstance, "button_up");
obj2 = new GameObject("sprite4");
obj2.transform.parent = this.spriteInstance.transform;
obj2.transform.localPosition = new Vector3(1f, -1f, 0f);
obj2.AddComponent<tk2dSprite>().SetSprite(this.spriteCollectionInstance, "Rock");
}
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:24,代码来源:tk2dDemoRuntimeSpriteController.cs
示例14: UsesSpriteCollection
// tk2dRuntime.ISpriteCollectionEditor
public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection)
{
if (data.font != null && data.font.spriteCollection != null)
return data.font.spriteCollection == spriteCollection;
// No easy way to identify this at this stage
return true;
}
开发者ID:dfos1,项目名称:Gladiator-Arena,代码行数:9,代码来源:tk2dTextMesh.cs
示例15: UsesSpriteCollection
// tk2dRuntime.ISpriteCollectionEditor
public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection)
{
// No easy way to identify this at this stage
return true;
}
开发者ID:stubuchbinder,项目名称:weave,代码行数:6,代码来源:tk2dTextMesh.cs
示例16: UsesSpriteCollection
public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection)
{
return this.spriteCollection == spriteCollection;
}
开发者ID:GlitchRevolution,项目名称:desolation-2014,代码行数:4,代码来源:tk2dStaticSpriteBatcher.cs
示例17: AttachPointSpriteHandler
void AttachPointSpriteHandler(tk2dSpriteCollectionData newSpriteCollection, int newSpriteId, object callbackData) {
string attachPointName = (string)callbackData;
tk2dSpriteCollection.AttachPointTestSprite proxy = null;
if (SpriteCollection.attachPointTestSprites.TryGetValue(attachPointName, out proxy)) {
proxy.spriteCollection = newSpriteCollection;
proxy.spriteId = newSpriteId;
HandleUtility.Repaint();
}
}
开发者ID:pan4,项目名称:NewTD,代码行数:9,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例18: SpriteChangedCallbackImpl
// Callback and delegate
void SpriteChangedCallbackImpl(tk2dSpriteCollectionData spriteCollection, int spriteId, object data)
{
tk2dBaseSprite s = target as tk2dBaseSprite;
if (s != null)
{
s.SwitchCollectionAndSprite(spriteCollection, spriteId);
s.EditMode__CreateCollider();
EditorUtility.SetDirty(target);
}
}
开发者ID:jpann,项目名称:MissileDefense,代码行数:11,代码来源:tk2dSpriteEditor.cs
示例19: AddComponent
/// <summary>
/// Adds a tk2dSprite as a component to the gameObject passed in, setting up necessary parameters and building geometry.
/// Convenience alias of tk2dBaseSprite.AddComponent<tk2dSprite>(...).
/// </summary>
public static tk2dSprite AddComponent(GameObject go, tk2dSpriteCollectionData spriteCollection, string spriteName)
{
return tk2dBaseSprite.AddComponent<tk2dSprite>(go, spriteCollection, spriteName);
}
开发者ID:GlitchRevolution,项目名称:desolation-2014,代码行数:8,代码来源:tk2dSprite.cs
示例20: BuildSpriteCollection
// Prefab build, 单次build缓存
public static string BuildSpriteCollection(tk2dSpriteCollectionData data)
{
if (data == null)
{
Log.Error("[BuildSpriteColleccion]Null SpriteCol Data!!!");
return "";
}
GameObject spriteColPrefab = PrefabUtility.FindPrefabRoot(data.gameObject) as GameObject;
Log.Assert(spriteColPrefab);
string path = AssetDatabase.GetAssetPath(spriteColPrefab); // prefab只用来获取路径,不打包不挖空
if (string.IsNullOrEmpty(path))
{
Log.Info("Null Sprite Collection {0}", path);
return ""; // !!! SpriteCollection可能动态生成的,不打包它
}
bool needBuild = BuildTools.CheckNeedBuild(path);
if (needBuild)
BuildTools.MarkBuildVersion(path);
path = __GetPrefabBuildPath(path);
GameObject copySpriteColObj = GameObject.Instantiate(spriteColPrefab) as GameObject;
tk2dSpriteCollectionData spriteColData = copySpriteColObj.GetComponent<tk2dSpriteCollectionData>();
foreach (Material mat in spriteColData.materials) // many materials
{
string matPath = BuildDepMaterial(mat, GameDef.PictureScale);
if (!string.IsNullOrEmpty(matPath)) // 材质可能动态创建的,无需打包
//CResourceDependencies.Create(spriteColData, CResourceDependencyType.SPRITE_COLLECTION, matPath);
KAssetDep.Create<CTk2dSpriteCollectionDep>(spriteColData, matPath);
}
spriteColData.materials = new Material[0]; // 挖空spriteCollections
spriteColData.textures = new Texture[0];
foreach (var def in spriteColData.spriteDefinitions)
{
def.material = null;
// 进行缩放!
//if (def.positions != null)
//{
// // position! size!
// for (var ip = 0; ip < def.positions.Length; ip++)
// {
// def.positions[ip] = def.positions[ip] / GameDef.PictureScale;
// }
// for (var ip = 0; ip < def.untrimmedBoundsData.Length; ip++)
// {
// def.untrimmedBoundsData[ip] = def.untrimmedBoundsData[ip] / GameDef.PictureScale;
// }
// for (var ip = 0; ip < def.boundsData.Length; ip++)
// {
// def.boundsData[ip] = def.boundsData[ip] / GameDef.PictureScale;
// }
//}
}
var result = DoBuildAssetBundle(DepBuildToFolder + "/Col_" + path, copySpriteColObj, needBuild); // Build主对象, 被挖空Material了的
GameObject.DestroyImmediate(copySpriteColObj);
return result.Path;
}
开发者ID:mr-kelly,项目名称:KEngine,代码行数:64,代码来源:CDepBuild_tk2dToolkit.cs
注:本文中的tk2dSpriteCollectionData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论