本文整理汇总了C#中tk2dSpriteCollectionDefinition类的典型用法代码示例。如果您正苦于以下问题:C# tk2dSpriteCollectionDefinition类的具体用法?C# tk2dSpriteCollectionDefinition怎么用?C# tk2dSpriteCollectionDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
tk2dSpriteCollectionDefinition类属于命名空间,在下文中一共展示了tk2dSpriteCollectionDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CheckAndFixUpParams
public static bool CheckAndFixUpParams(tk2dSpriteCollection gen)
{
if (gen.DoNotUse__TextureRefs != null && gen.textureParams != null && gen.DoNotUse__TextureRefs.Length != gen.textureParams.Length)
{
tk2dSpriteCollectionDefinition[] newDefs = new tk2dSpriteCollectionDefinition[gen.DoNotUse__TextureRefs.Length];
int c = Mathf.Min( newDefs.Length, gen.textureParams.Length );
if (gen.DoNotUse__TextureRefs.Length > gen.textureParams.Length)
{
Texture2D[] newTexRefs = new Texture2D[gen.DoNotUse__TextureRefs.Length - gen.textureParams.Length];
System.Array.Copy(gen.DoNotUse__TextureRefs, gen.textureParams.Length, newTexRefs, 0, newTexRefs.Length);
System.Array.Sort(newTexRefs, (Texture2D a, Texture2D b) => tk2dSpriteGuiUtility.NameCompare(a?a.name:"", b?b.name:""));
System.Array.Copy(newTexRefs, 0, gen.DoNotUse__TextureRefs, gen.textureParams.Length, newTexRefs.Length);
}
for (int i = 0; i < c; ++i)
{
newDefs[i] = new tk2dSpriteCollectionDefinition();
newDefs[i].CopyFrom( gen.textureParams[i] );
}
for (int i = c; i < newDefs.Length; ++i)
{
newDefs[i] = new tk2dSpriteCollectionDefinition();
newDefs[i].pad = gen.defaults.pad;
newDefs[i].additive = gen.defaults.additive;
newDefs[i].anchor = gen.defaults.anchor;
newDefs[i].scale = gen.defaults.scale;
newDefs[i].colliderType = gen.defaults.colliderType;
}
gen.textureParams = newDefs;
}
// clear thumbnails on build
foreach (var param in gen.textureParams)
{
param.thumbnailTexture = null;
}
foreach (var param in gen.textureParams)
{
if (gen.allowMultipleAtlases && param.dice)
{
EditorUtility.DisplayDialog("Error",
"Multiple atlas spanning is not allowed when there are textures with dicing enabled in the SpriteCollection.",
"Ok");
gen.allowMultipleAtlases = false;
return false;
}
}
return true;
}
开发者ID:AtwoodDeng,项目名称:GGJ2015,代码行数:54,代码来源:tk2dSpriteCollectionBuilderDeprecated.cs
示例2: DrawCustomBoxColliderEditor
void DrawCustomBoxColliderEditor(Rect r, tk2dSpriteCollectionDefinition param, Texture2D tex)
{
Vector3[] pt = new Vector3[] {
new Vector3(param.boxColliderMin.x * displayScale, param.boxColliderMin.y * displayScale, 0.0f),
new Vector3(param.boxColliderMax.x * displayScale, param.boxColliderMin.y * displayScale, 0.0f),
new Vector3(param.boxColliderMax.x * displayScale, param.boxColliderMax.y * displayScale, 0.0f),
new Vector3(param.boxColliderMin.x * displayScale, param.boxColliderMax.y * displayScale, 0.0f),
};
Color32 transparentColor = handleInactiveColor;
transparentColor.a = 10;
Handles.DrawSolidRectangleWithOutline(pt, transparentColor, handleInactiveColor);
// Draw grab handles
Vector3 handlePos;
// Draw top handle
handlePos = (pt[0] + pt[1]) * 0.5f;
handlePos = tk2dGuiUtility.PositionHandle(16433 + 0, handlePos, 4.0f, handleInactiveColor, handleActiveColor) / displayScale;
param.boxColliderMin.y = handlePos.y;
if (param.boxColliderMin.y > param.boxColliderMax.y) param.boxColliderMin.y = param.boxColliderMax.y;
// Draw bottom handle
handlePos = (pt[2] + pt[3]) * 0.5f;
handlePos = tk2dGuiUtility.PositionHandle(16433 + 1, handlePos, 4.0f, handleInactiveColor, handleActiveColor) / displayScale;
param.boxColliderMax.y = handlePos.y;
if (param.boxColliderMax.y < param.boxColliderMin.y) param.boxColliderMax.y = param.boxColliderMin.y;
// Draw left handle
handlePos = (pt[0] + pt[3]) * 0.5f;
handlePos = tk2dGuiUtility.PositionHandle(16433 + 2, handlePos, 4.0f, handleInactiveColor, handleActiveColor) / displayScale;
param.boxColliderMin.x = handlePos.x;
if (param.boxColliderMin.x > param.boxColliderMax.x) param.boxColliderMin.x = param.boxColliderMax.x;
// Draw right handle
handlePos = (pt[1] + pt[2]) * 0.5f;
handlePos = tk2dGuiUtility.PositionHandle(16433 + 3, handlePos, 4.0f, handleInactiveColor, handleActiveColor) / displayScale;
param.boxColliderMax.x = handlePos.x;
if (param.boxColliderMax.x < param.boxColliderMin.x) param.boxColliderMax.x = param.boxColliderMin.x;
param.boxColliderMax.x = Mathf.Round(param.boxColliderMax.x);
param.boxColliderMax.y = Mathf.Round(param.boxColliderMax.y);
param.boxColliderMin.x = Mathf.Round(param.boxColliderMin.x);
param.boxColliderMin.y = Mathf.Round(param.boxColliderMin.y);
// constrain
param.boxColliderMax.x = Mathf.Clamp(param.boxColliderMax.x, 0.0f, tex.width);
param.boxColliderMax.y = Mathf.Clamp(param.boxColliderMax.y, 0.0f, tex.height);
param.boxColliderMin.x = Mathf.Clamp(param.boxColliderMin.x, 0.0f, tex.width);
param.boxColliderMin.y = Mathf.Clamp(param.boxColliderMin.y, 0.0f, tex.height);
}
开发者ID:CodeStrumpet,项目名称:Elemental,代码行数:50,代码来源:tk2dSpriteCollectionEditorPopup.cs
示例3: DrawTextureInspector
public void DrawTextureInspector(tk2dSpriteCollectionDefinition param, Texture2D texture)
{
if (mode == Mode.Collider && param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon)
{
tk2dGuiUtility.InfoBox("Points" +
"\nClick drag - move point" +
"\nClick hold + delete/bkspace - delete point" +
"\nDouble click on line - add point", tk2dGuiUtility.WarningLevel.Info);
tk2dGuiUtility.InfoBox("Islands" +
"\nClick hold point + X - delete island" +
"\nPress C - create island at cursor" +
"\nClick hold point + T - toggle connected" +
"\nClick hold point + F - flip island", tk2dGuiUtility.WarningLevel.Info);
}
}
开发者ID:GennrichJ,项目名称:GalaxyWars,代码行数:16,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例4: CompareTo
public bool CompareTo(tk2dSpriteCollectionDefinition.ColliderData src)
{
return ((((this.name == src.name) && (this.type == src.type)) && ((this.origin == src.origin) && (this.size == src.size))) && (this.angle == src.angle));
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:4,代码来源:tk2dSpriteCollectionDefinition.cs
示例5: DrawSpritePropertiesPanel
void DrawSpritePropertiesPanel(ref int currSprite, ref tk2dSpriteCollectionDefinition param)
{
currSprite = tk2dEditorUtility.SpriteSelectorPopup(null, currSprite, gen.spriteCollection);
param = gen.textureParams[currSprite];
if (param.fromSpriteSheet)
{
EditorGUILayout.LabelField("SpriteSheet", "Frame: " + param.regionId);
EditorGUILayout.LabelField("Name", param.name);
}
else
{
param.name = EditorGUILayout.TextField("Name", param.name);
}
if (!param.fromSpriteSheet)
{
param.additive = EditorGUILayout.Toggle("Additive", param.additive);
param.scale = EditorGUILayout.Vector3Field("Scale", param.scale);
param.anchor = (tk2dSpriteCollectionDefinition.Anchor)EditorGUILayout.EnumPopup("Anchor", param.anchor);
if (param.anchor == tk2dSpriteCollectionDefinition.Anchor.Custom)
{
EditorGUILayout.BeginHorizontal();
param.anchorX = EditorGUILayout.FloatField("AnchorX", param.anchorX);
bool roundAnchorX = GUILayout.Button("R", GUILayout.MaxWidth(32));
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
param.anchorY = EditorGUILayout.FloatField("AnchorY", param.anchorY);
bool roundAnchorY = GUILayout.Button("R", GUILayout.MaxWidth(32));
EditorGUILayout.EndHorizontal();
drawAnchor = EditorGUILayout.Toggle("Draw anchor", drawAnchor);
if (roundAnchorX) param.anchorX = Mathf.Round(param.anchorX);
if (roundAnchorY) param.anchorY = Mathf.Round(param.anchorY);
}
if (!gen.allowMultipleAtlases)
{
param.dice = EditorGUILayout.Toggle("Dice", param.dice);
if (param.dice)
{
param.diceUnitX = EditorGUILayout.IntField("X", param.diceUnitX);
param.diceUnitY = EditorGUILayout.IntField("Y", param.diceUnitY);
}
}
param.pad = (tk2dSpriteCollectionDefinition.Pad)EditorGUILayout.EnumPopup("Pad", param.pad);
EditorGUILayout.Separator();
}
// Warning message
if (gen.allowMultipleAtlases)
{
Color bg = GUI.backgroundColor;
GUI.backgroundColor = new Color(1.0f, 0.7f, 0.0f, 1.0f);
GUILayout.TextArea("NOTE: Dicing is not allowed when multiple atlas build is enabled.");
GUI.backgroundColor = bg;
}
}
开发者ID:CodeStrumpet,项目名称:Elemental,代码行数:61,代码来源:tk2dSpriteCollectionEditorPopup.cs
示例6: DrawAdvancedColliderEditor
void DrawAdvancedColliderEditor(Rect r, tk2dSpriteCollectionDefinition param, Texture2D tex) {
int controlId = advancedColliderEditorControlBase.GetHashCode();
Vector2 origin = new Vector2(r.x, r.y);
for (int pass = 0; pass < 2; ++pass) {
for (int i = 0; i < param.colliderData.Count; ++i) {
int thisControlId = controlId + i;
// process selected control first, this could be written better
if (pass == 0 && thisControlId != GUIUtility.hotControl && thisControlId != tk2dGuiUtility.ActiveTweakable) { continue; }
else if (pass == 1 && (thisControlId == GUIUtility.hotControl || thisControlId == tk2dGuiUtility.ActiveTweakable)) { continue; }
tk2dSpriteCollectionDefinition.ColliderData data = param.colliderData[i];
if (data.type == tk2dSpriteCollectionDefinition.ColliderData.Type.Circle) {
tk2dGuiUtility.TweakableCircle( thisControlId, origin + data.origin * editorDisplayScale, data.size.x * editorDisplayScale,
delegate(Vector2 pos, float radius) {
data.origin = ( pos - origin ) / editorDisplayScale;
radius /= editorDisplayScale;
data.size.Set( radius, radius );
} );
}
else if (data.type == tk2dSpriteCollectionDefinition.ColliderData.Type.Box) {
tk2dGuiUtility.TweakableBox( thisControlId, origin + data.origin * editorDisplayScale, data.size * editorDisplayScale, data.angle,
delegate(Vector2 pos, Vector2 size, float angle) {
data.origin = ( pos - origin ) / editorDisplayScale;
data.size = size / editorDisplayScale;
data.angle = angle;
} );
}
if (tk2dGuiUtility.ActiveTweakable == thisControlId && currentInspectedColliderData != param.colliderData[i]) {
int rr = i;
deferredAction = delegate(int q) {
currentInspectedColliderData = param.colliderData[rr];
};
}
}
}
Event ev = Event.current;
tk2dSpriteCollectionDefinition.ColliderData selection = SelectedColliderData(param, false);
if (selection != null) {
if (ev.type == EventType.ValidateCommand && ev.commandName == "Duplicate") {
ev.Use();
}
else if (ev.type == EventType.ExecuteCommand && ev.commandName == "Duplicate") {
tk2dSpriteCollectionDefinition.ColliderData dup = new tk2dSpriteCollectionDefinition.ColliderData();
dup.CopyFrom(selection);
dup.origin += new Vector2(10, 10);
param.colliderData.Add(dup);
tk2dGuiUtility.ActiveTweakable = controlId + param.colliderData.Count - 1;
HandleUtility.Repaint();
ev.Use();
}
if (ev.type == EventType.ValidateCommand && ev.commandName == "Delete") {
ev.Use();
}
else if (ev.type == EventType.ExecuteCommand && ev.commandName == "Delete") {
param.colliderData.Remove(selection);
tk2dGuiUtility.ActiveTweakable = 0;
GUIUtility.hotControl = 0;
ev.Use();
}
if (ev.type == EventType.MouseDown) {
tk2dGuiUtility.ActiveTweakable = 0;
GUIUtility.hotControl = 0;
currentInspectedColliderData = null;
}
if (ev.type == EventType.KeyDown) {
switch (ev.keyCode) {
case KeyCode.Escape:
tk2dGuiUtility.ActiveTweakable = 0;
GUIUtility.hotControl = 0;
currentInspectedColliderData = null;
ev.Use();
break;
case KeyCode.RightBracket:
case KeyCode.Tab:
int selectionIdx = 0;
for (int i = 0; i < param.colliderData.Count; ++i) {
if (param.colliderData[i] == selection) {
currentInspectedColliderData = param.colliderData[i];
selectionIdx = i;
break;
}
}
tk2dGuiUtility.ActiveTweakable = advancedColliderEditorControlBase + ((selectionIdx + 1) % param.colliderData.Count);
HandleUtility.Repaint();
ev.Use();
break;
case KeyCode.UpArrow: selection.origin += new Vector2(0, -1); ev.Use(); break;
case KeyCode.DownArrow: selection.origin += new Vector2(0, 1); ev.Use(); break;
case KeyCode.LeftArrow: selection.origin += new Vector2(-1, 0); ev.Use(); break;
case KeyCode.RightArrow: selection.origin += new Vector2(1, 0); ev.Use(); break;
}
}
}
//.........这里部分代码省略.........
开发者ID:pan4,项目名称:NewTD,代码行数:101,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例7: DrawToolbar
public void DrawToolbar(tk2dSpriteCollectionDefinition param, Texture2D texture)
{
bool allowAnchor = param.anchor == tk2dSpriteCollectionDefinition.Anchor.Custom;
bool allowCollider = (param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon ||
param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.BoxCustom ||
param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Advanced);
bool allowAttachPoint = true;
GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
mode = GUILayout.Toggle((mode == Mode.Texture), new GUIContent("Sprite", "Shift+Q"), EditorStyles.toolbarButton)?Mode.Texture:mode;
if (allowAnchor)
mode = GUILayout.Toggle((mode == Mode.Anchor), new GUIContent("Anchor", "Shift+W"), EditorStyles.toolbarButton)?Mode.Anchor:mode;
if (allowCollider)
mode = GUILayout.Toggle((mode == Mode.Collider), new GUIContent("Collider", "Shift+E"), EditorStyles.toolbarButton)?Mode.Collider:mode;
if (allowAttachPoint)
mode = GUILayout.Toggle((mode == Mode.AttachPoint), new GUIContent("AttachPoint", "Shift+R"), EditorStyles.toolbarButton)?Mode.AttachPoint:mode;
GUILayout.FlexibleSpace();
if (tk2dGuiUtility.HasActivePositionHandle)
{
string str = "X: " + tk2dGuiUtility.ActiveHandlePosition.x + " Y: " + tk2dGuiUtility.ActiveHandlePosition.y;
GUILayout.Label(str, EditorStyles.toolbarTextField);
}
if ((mode == Mode.Collider && param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon) ||
(mode == Mode.Texture && param.customSpriteGeometry))
{
drawColliderNormals = GUILayout.Toggle(drawColliderNormals, new GUIContent("Show Normals", "Shift+N"), EditorStyles.toolbarButton);
}
if (mode == Mode.Texture && texture != null) {
GUILayout.Label(string.Format("W: {0} H: {1}", texture.width, texture.height));
}
GUILayout.EndHorizontal();
}
开发者ID:pan4,项目名称:NewTD,代码行数:34,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例8: DrawTextureInspector
public void DrawTextureInspector(tk2dSpriteCollectionDefinition param, Texture2D texture)
{
if (mode == Mode.Collider && param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon)
{
param.colliderColor = (tk2dSpriteCollectionDefinition.ColliderColor)EditorGUILayout.EnumPopup("Display Color", param.colliderColor);
tk2dGuiUtility.InfoBox("Points" +
"\nClick drag - move point" +
"\nClick hold + delete/bkspace - delete point" +
"\nDouble click on line - add point", tk2dGuiUtility.WarningLevel.Info);
tk2dGuiUtility.InfoBox("Islands" +
"\nClick hold point + X - delete island" +
"\nPress C - create island at cursor" +
"\nClick hold point + T - toggle connected" +
"\nClick hold point + F - flip island", tk2dGuiUtility.WarningLevel.Info);
}
else if (mode == Mode.Collider && param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Advanced) {
DrawAdvancedColliderInspector(param, texture);
}
if (mode == Mode.Texture && param.customSpriteGeometry)
{
param.colliderColor = (tk2dSpriteCollectionDefinition.ColliderColor)EditorGUILayout.EnumPopup("Display Color", param.colliderColor);
tk2dGuiUtility.InfoBox("Points" +
"\nClick drag - move point" +
"\nClick hold + delete/bkspace - delete point" +
"\nDouble click on line - add point", tk2dGuiUtility.WarningLevel.Info);
tk2dGuiUtility.InfoBox("Islands" +
"\nClick hold point + X - delete island" +
"\nPress C - create island at cursor" +
"\nClick hold point + F - flip island", tk2dGuiUtility.WarningLevel.Info);
}
if (mode == Mode.AttachPoint) {
DrawAttachPointInspector( param, texture );
}
if (deferredAction != null) {
if (Event.current.type == EventType.Repaint) {
deferredAction(0);
deferredAction = null;
}
else {
HandleUtility.Repaint();
}
}
}
开发者ID:pan4,项目名称:NewTD,代码行数:48,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例9: SelectedColliderData
tk2dSpriteCollectionDefinition.ColliderData SelectedColliderData(tk2dSpriteCollectionDefinition param, bool allowActive) {
int selectedColliderData = tk2dGuiUtility.ActiveTweakable - advancedColliderEditorControlBase;
if (allowActive && (selectedColliderData < 0 || selectedColliderData >= param.colliderData.Count)) {
selectedColliderData = GUIUtility.hotControl - advancedColliderEditorControlBase;
}
return (selectedColliderData < 0 || selectedColliderData >= param.colliderData.Count) ? null : param.colliderData[selectedColliderData];
}
开发者ID:pan4,项目名称:NewTD,代码行数:7,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例10: CompareTo
public bool CompareTo(tk2dSpriteCollectionDefinition src)
{
if (name != src.name) return false;
if (additive != src.additive) return false;
if (scale != src.scale) return false;
if (texture != src.texture) return false;
if (anchor != src.anchor) return false;
if (anchorX != src.anchorX) return false;
if (anchorY != src.anchorY) return false;
if (overrideMesh != src.overrideMesh) return false;
if (dice != src.dice) return false;
if (diceUnitX != src.diceUnitX) return false;
if (diceUnitY != src.diceUnitY) return false;
if (pad != src.pad) return false;
if (fromSpriteSheet != src.fromSpriteSheet) return false;
if (extractRegion != src.extractRegion) return false;
if (regionX != src.regionX) return false;
if (regionY != src.regionY) return false;
if (regionW != src.regionW) return false;
if (regionH != src.regionH) return false;
if (regionId != src.regionId) return false;
if (colliderType != src.colliderType) return false;
if (boxColliderMin != src.boxColliderMin) return false;
if (boxColliderMax != src.boxColliderMax) return false;
if (polyColliderIslands != src.polyColliderIslands) return false;
if (polyColliderIslands != null && src.polyColliderIslands != null)
{
if (polyColliderIslands.Length != src.polyColliderIslands.Length) return false;
for (int i = 0; i < polyColliderIslands.Length; ++i)
if (!polyColliderIslands[i].CompareTo(src.polyColliderIslands[i])) return false;
}
if (polyColliderCap != src.polyColliderCap) return false;
if (colliderColor != src.colliderColor) return false;
if (colliderSmoothSphereCollisions != src.colliderSmoothSphereCollisions) return false;
if (colliderConvex != src.colliderConvex) return false;
return true;
}
开发者ID:CodeStrumpet,项目名称:Elemental,代码行数:44,代码来源:tk2dSpriteCollection.cs
示例11: SetUpSpriteSheets
static bool SetUpSpriteSheets(tk2dSpriteCollection gen)
{
// delete textures which aren't in sprite sheets any more
// and delete textures which are out of range of the spritesheet
for (int i = 0; i < gen.textureRefs.Length; ++i)
{
if (gen.textureParams[i].fromSpriteSheet)
{
bool found = false;
foreach (var ss in gen.spriteSheets)
{
if (gen.textureRefs[i] == ss.texture)
{
found = true;
int numTiles = (ss.numTiles == 0)?(ss.tilesX * ss.tilesY):Mathf.Min(ss.numTiles, ss.tilesX * ss.tilesY);
// delete textures which are out of range
if (gen.textureParams[i].regionId >= numTiles)
{
gen.textureRefs[i] = null;
gen.textureParams[i].fromSpriteSheet = false;
gen.textureParams[i].extractRegion = false;
gen.textureParams[i].colliderType = tk2dSpriteCollectionDefinition.ColliderType.None;
gen.textureParams[i].boxColliderMin = Vector3.zero;
gen.textureParams[i].boxColliderMax = Vector3.zero;
}
}
}
if (!found)
{
gen.textureRefs[i] = null;
gen.textureParams[i].fromSpriteSheet = false;
gen.textureParams[i].extractRegion = false;
gen.textureParams[i].colliderType = tk2dSpriteCollectionDefinition.ColliderType.None;
gen.textureParams[i].boxColliderMin = Vector3.zero;
gen.textureParams[i].boxColliderMax = Vector3.zero;
}
}
}
if (gen.spriteSheets == null)
{
gen.spriteSheets = new tk2dSpriteSheetSource[0];
}
int spriteSheetId = 0;
for (spriteSheetId = 0; spriteSheetId < gen.spriteSheets.Length; ++spriteSheetId)
{
var spriteSheet = gen.spriteSheets[spriteSheetId];
// New mode sprite sheets have sprites already created
if (spriteSheet.version > 0)
continue;
// Sanity check
if (spriteSheet.texture == null)
{
continue; // deleted, safely ignore this
}
if (spriteSheet.tilesX * spriteSheet.tilesY == 0 ||
(spriteSheet.numTiles != 0 && spriteSheet.numTiles > spriteSheet.tilesX * spriteSheet.tilesY))
{
EditorUtility.DisplayDialog("Invalid sprite sheet",
"Sprite sheet '" + spriteSheet.texture.name + "' has an invalid number of tiles",
"Ok");
return false;
}
if ((spriteSheet.texture.width % spriteSheet.tilesX) != 0 || (spriteSheet.texture.height % spriteSheet.tilesY) != 0)
{
EditorUtility.DisplayDialog("Invalid sprite sheet",
"Sprite sheet '" + spriteSheet.texture.name + "' doesn't match tile count",
"Ok");
return false;
}
int numTiles = (spriteSheet.numTiles == 0)?(spriteSheet.tilesX * spriteSheet.tilesY):Mathf.Min(spriteSheet.numTiles, spriteSheet.tilesX * spriteSheet.tilesY);
for (int y = 0; y < spriteSheet.tilesY; ++y)
{
for (int x = 0; x < spriteSheet.tilesX; ++x)
{
// limit to number of tiles, if told to
int tileIdx = y * spriteSheet.tilesX + x;
if (tileIdx >= numTiles)
break;
bool foundInCollection = false;
// find texture in collection
int textureIdx = -1;
for (int i = 0; i < gen.textureParams.Length; ++i)
{
if (gen.textureParams[i].fromSpriteSheet
&& gen.textureParams[i].regionId == tileIdx
&& gen.textureRefs[i] == spriteSheet.texture)
{
textureIdx = i;
foundInCollection = true;
break;
}
}
//.........这里部分代码省略.........
开发者ID:GennrichJ,项目名称:GalaxyWars,代码行数:101,代码来源:tk2dSpriteCollectionBuilder.cs
示例12: CopyFrom
public void CopyFrom(tk2dSpriteCollectionDefinition src)
{
name = src.name;
disableTrimming = src.disableTrimming;
additive = src.additive;
scale = src.scale;
texture = src.texture;
materialId = src.materialId;
anchor = src.anchor;
anchorX = src.anchorX;
anchorY = src.anchorY;
overrideMesh = src.overrideMesh;
customSpriteGeometry = src.customSpriteGeometry;
geometryIslands = src.geometryIslands;
dice = src.dice;
diceUnitX = src.diceUnitX;
diceUnitY = src.diceUnitY;
pad = src.pad;
source = src.source;
fromSpriteSheet = src.fromSpriteSheet;
hasSpriteSheetId = src.hasSpriteSheetId;
spriteSheetX = src.spriteSheetX;
spriteSheetY = src.spriteSheetY;
spriteSheetId = src.spriteSheetId;
extractRegion = src.extractRegion;
regionX = src.regionX;
regionY = src.regionY;
regionW = src.regionW;
regionH = src.regionH;
regionId = src.regionId;
colliderType = src.colliderType;
boxColliderMin = src.boxColliderMin;
boxColliderMax = src.boxColliderMax;
polyColliderCap = src.polyColliderCap;
colliderColor = src.colliderColor;
colliderConvex = src.colliderConvex;
colliderSmoothSphereCollisions = src.colliderSmoothSphereCollisions;
extraPadding = src.extraPadding;
if (src.polyColliderIslands != null)
{
polyColliderIslands = new tk2dSpriteColliderIsland[src.polyColliderIslands.Length];
for (int i = 0; i < polyColliderIslands.Length; ++i)
{
polyColliderIslands[i] = new tk2dSpriteColliderIsland();
polyColliderIslands[i].CopyFrom(src.polyColliderIslands[i]);
}
}
else
{
polyColliderIslands = new tk2dSpriteColliderIsland[0];
}
if (src.geometryIslands != null)
{
geometryIslands = new tk2dSpriteColliderIsland[src.geometryIslands.Length];
for (int i = 0; i < geometryIslands.Length; ++i)
{
geometryIslands[i] = new tk2dSpriteColliderIsland();
geometryIslands[i].CopyFrom(src.geometryIslands[i]);
}
}
else
{
geometryIslands = new tk2dSpriteColliderIsland[0];
}
}
开发者ID:hyf042,项目名称:BakeryGirl-chess,代码行数:74,代码来源:tk2dSpriteCollection.cs
示例13: CopyFrom
public void CopyFrom(tk2dSpriteCollectionDefinition src)
{
this.name = src.name;
this.disableTrimming = src.disableTrimming;
this.additive = src.additive;
this.scale = src.scale;
this.texture = src.texture;
this.materialId = src.materialId;
this.anchor = src.anchor;
this.anchorX = src.anchorX;
this.anchorY = src.anchorY;
this.overrideMesh = src.overrideMesh;
this.doubleSidedSprite = src.doubleSidedSprite;
this.customSpriteGeometry = src.customSpriteGeometry;
this.geometryIslands = src.geometryIslands;
this.dice = src.dice;
this.diceUnitX = src.diceUnitX;
this.diceUnitY = src.diceUnitY;
this.diceFilter = src.diceFilter;
this.pad = src.pad;
this.source = src.source;
this.fromSpriteSheet = src.fromSpriteSheet;
this.hasSpriteSheetId = src.hasSpriteSheetId;
this.spriteSheetX = src.spriteSheetX;
this.spriteSheetY = src.spriteSheetY;
this.spriteSheetId = src.spriteSheetId;
this.extractRegion = src.extractRegion;
this.regionX = src.regionX;
this.regionY = src.regionY;
this.regionW = src.regionW;
this.regionH = src.regionH;
this.regionId = src.regionId;
this.colliderType = src.colliderType;
this.boxColliderMin = src.boxColliderMin;
this.boxColliderMax = src.boxColliderMax;
this.polyColliderCap = src.polyColliderCap;
this.colliderColor = src.colliderColor;
this.colliderConvex = src.colliderConvex;
this.colliderSmoothSphereCollisions = src.colliderSmoothSphereCollisions;
this.extraPadding = src.extraPadding;
this.colliderData = new List<ColliderData>(src.colliderData.Count);
foreach (ColliderData data in src.colliderData)
{
ColliderData item = new ColliderData();
item.CopyFrom(data);
this.colliderData.Add(item);
}
if (src.polyColliderIslands != null)
{
this.polyColliderIslands = new tk2dSpriteColliderIsland[src.polyColliderIslands.Length];
for (int i = 0; i < this.polyColliderIslands.Length; i++)
{
this.polyColliderIslands[i] = new tk2dSpriteColliderIsland();
this.polyColliderIslands[i].CopyFrom(src.polyColliderIslands[i]);
}
}
else
{
this.polyColliderIslands = new tk2dSpriteColliderIsland[0];
}
if (src.geometryIslands != null)
{
this.geometryIslands = new tk2dSpriteColliderIsland[src.geometryIslands.Length];
for (int j = 0; j < this.geometryIslands.Length; j++)
{
this.geometryIslands[j] = new tk2dSpriteColliderIsland();
this.geometryIslands[j].CopyFrom(src.geometryIslands[j]);
}
}
else
{
this.geometryIslands = new tk2dSpriteColliderIsland[0];
}
this.attachPoints = new List<tk2dSpriteDefinition.AttachPoint>(src.attachPoints.Count);
foreach (tk2dSpriteDefinition.AttachPoint point in src.attachPoints)
{
tk2dSpriteDefinition.AttachPoint point2 = new tk2dSpriteDefinition.AttachPoint();
point2.CopyFrom(point);
this.attachPoints.Add(point2);
}
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:81,代码来源:tk2dSpriteCollectionDefinition.cs
示例14: Clear
public void Clear()
{
// Reinitialize
var tmpVar = new tk2dSpriteCollectionDefinition();
CopyFrom(tmpVar);
}
开发者ID:hyf042,项目名称:BakeryGirl-chess,代码行数:6,代码来源:tk2dSpriteCollection.cs
示例15: CompareTo
public bool CompareTo(tk2dSpriteCollectionDefinition src)
{
if (name != src.name) return false;
if (additive != src.additive) return false;
if (scale != src.scale) return false;
if (texture != src.texture) return false;
if (materialId != src.materialId) return false;
if (anchor != src.anchor) return false;
if (anchorX != src.anchorX) return false;
if (anchorY != src.anchorY) return false;
if (overrideMesh != src.overrideMesh) return false;
if (dice != src.dice) return false;
if (diceUnitX != src.diceUnitX) return false;
if (diceUnitY != src.diceUnitY) return false;
if (diceFilter != src.diceFilter) return false;
if (pad != src.pad) return false;
if (extraPadding != src.extraPadding) return false;
if (doubleSidedSprite != src.doubleSidedSprite) return false;
if (customSpriteGeometry != src.customSpriteGeometry) return false;
if (geometryIslands != src.geometryIslands) return false;
if (geometryIslands != null && src.geometryIslands != null)
{
if (geometryIslands.Length != src.geometryIslands.Length) return false;
for (int i = 0; i < geometryIslands.Length; ++i)
if (!geometryIslands[i].CompareTo(src.geometryIslands[i])) return false;
}
if (source != src.source) return false;
if (fromSpriteSheet != src.fromSpriteSheet) return false;
if (hasSpriteSheetId != src.hasSpriteSheetId) return false;
if (spriteSheetId != src.spriteSheetId) return false;
if (spriteSheetX != src.spriteSheetX) return false;
if (spriteSheetY != src.spriteSheetY) return false;
if (extractRegion != src.extractRegion) return false;
if (regionX != src.regionX) return false;
if (regionY != src.regionY) return false;
if (regionW != src.regionW) return false;
if (regionH != src.regionH) return false;
if (regionId != src.regionId) return false;
if (colliderType != src.colliderType) return false;
if (boxColliderMin != src.boxColliderMin) return false;
if (boxColliderMax != src.boxColliderMax) return false;
if (polyColliderIslands != src.polyColliderIslands) return false;
if (polyColliderIslands != null && src.polyColliderIslands != null)
{
if (polyColliderIslands.Length != src.polyColliderIslands.Length) return false;
for (int i = 0; i < polyColliderIslands.Length; ++i)
if (!polyColliderIslands[i].CompareTo(src.polyColliderIslands[i])) return false;
}
if (polyColliderCap != src.polyColliderCap) return false;
if (colliderColor != src.colliderColor) return false;
if (colliderSmoothSphereCollisions != src.colliderSmoothSphereCollisions) return false;
if (colliderConvex != src.colliderConvex) return false;
if (attachPoints.Count != src.attachPoints.Count) return false;
for (int i = 0; i < attachPoints.Count; ++i) {
if (!attachPoints[i].CompareTo(src.attachPoints[i])) return false;
}
return true;
}
开发者ID:rbrt,项目名称:heritagequest,代码行数:68,代码来源:tk2dSpriteCollection.cs
示例16: DrawToolbar
public void DrawToolbar(tk2dSpriteCollectionDefinition param)
{
bool allowAnchor = param.anchor == tk2dSpriteCollectionDefinition.Anchor.Custom;
bool allowCollider = (param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon ||
param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.BoxCustom);
GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
mode = GUILayout.Toggle((mode == Mode.Texture), "Sprite", EditorStyles.toolbarButton)?Mode.Texture:mode;
if (allowAnchor)
mode = GUILayout.Toggle((mode == Mode.Anchor), "Anchor", EditorStyles.toolbarButton)?Mode.Anchor:mode;
if (allowCollider)
mode = GUILayout.Toggle((mode == Mode.Collider), "Collider", EditorStyles.toolbarButton)?Mode.Collider:mode;
GUILayout.FlexibleSpace();
if ((mode == Mode.Collider && param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon) ||
(mode == Mode.Texture && param.customSpriteGeometry))
{
drawColliderNormals = GUILayout.Toggle(drawColliderNormals, "Show Normals", EditorStyles.toolbarButton);
}
GUILayout.EndHorizontal();
}
开发者ID:britg,项目名称:Pyroclasm,代码行数:21,代码来源:tk2dSpriteCollectionEditorTextureView.cs
示例17: DrawTextureView
public void DrawTextureView(tk2dSpriteCollectionDefinition param, Texture2D texture)
{
if (mode == Mode.None)
mode = Mode.Texture;
// sanity check
if (editorDisplayScale <= 1.0f) editorDisplayScale = 1.0f;
// mirror data
currentColliderColor = param.colliderColor;
GUILayout.BeginVertical(tk2dEditorSkin.SC_BodyBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
bool allowAnchor = param.anchor == tk2dSpriteCollectionDefinition.Anchor.Custom;
bool allowCollider = (param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon ||
param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.BoxCustom);
if (mode == Mode.Anchor && !allowAnchor) mode = Mode.Texture;
if (mode == Mode.Collider && !allowCollider) mode = Mode.Texture;
Rect rect = GUILayoutUtility.GetRect(128.0f, 128.0f, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
// middle mouse drag and scroll zoom
if (rect.Contains(Event.current.mousePosition))
{
if (Event.current.type == EventType.MouseDrag && Event.current.button == 2)
{
textureScrollPos -= Event.current.delta * editorDisplayScale;
Event.current.Use();
HandleUtility.Repaint();
}
if (Event.current.type == EventType.ScrollWheel)
{
editorDisplayScale -= Event.current.delta.y * 0.03f;
Event.current.Use();
HandleUtility.Repaint();
}
}
bool alphaBlend = true;
textureScrollPos = GUI.BeginScrollView(rect, textureScrollPos, new Rect(0, 0, (texture.width) * editorDisplayScale, (texture.height) * editorDisplayScale));
Rect textureRect = new Rect(0, 0, texture.width * editorDisplayScale, texture.height * editorDisplayScale);
texture.filterMode = FilterMode.Point;
GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleAndCrop, alphaBlend);
if (mode == Mode.Collider)
{
if (param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.BoxCustom)
DrawCustomBoxColliderEditor(textureRect, param, texture);
if (param.colliderType == tk2dSpriteCollectionDefinition.ColliderType.Polygon)
DrawPolygonColliderEditor(textureRect, ref param.polyColliderIslands, texture, false);
}
if (mode == Mode.Texture && param.customSpriteGeometry)
{
DrawPolygonColliderEditor(textureRect, ref param.geometryIslands, texture, true);
}
// Anchor
if (mode == Mode.Anchor)
{
Color handleColor = new Color(0,0,0,0.2f);
Color lineColor = Color.white;
Vector2 anchor = new Vector2(param.anchorX, param.anchorY);
anchor = tk2dGuiUtility.PositionHandle(99999, anchor * editorDisplayScale, 12.0f, handleColor, handleColor ) / editorDisplayScale;
Color oldColor = Handles.color;
Handles.color = lineColor;
float w = Mathf.Max(rect.width, texture.width * editorDisplayScale);
float h = Mathf.Max(rect.height, texture.height * editorDisplayScale);
Handles.DrawLine(new Vector3(0, anchor.y * editorDisplayScale, 0), new Vector3(w, anchor.y * editorDisplayScale, 0));
Handles.DrawLine(new Vector3(anchor.x * editorDisplayScale, 0, 0), new Vector3(anchor.x * editorDisplayScale, h, 0));
Handles.color = oldColor;
// constrain
param.anchorX = Mathf.Clamp(Mathf.Round(anchor.x), 0.0f, texture.width);
param.anchorY = Mathf.Clamp(Mathf.Round(anchor.y), 0.0f, texture.height);
HandleUtility.Repaint();
}
GUI.EndScrollView();
// Draw toolbar
DrawToolbar(param);
GUILayout.EndVertical();
}
开发者ID:britg,项目名称:Pyroclasm,代码行数:87,代码来源:tk2dSpriteCollectionEditorTextureView.cs
|
请发表评论