Position of vertices doesn’t show up in the skinning editor , how can i see position of these vertices?
Skinning Editor doesn’t have that functionality. Is it a functionality that you would like to use?
I want to create vertices at some certain positions , but now I just can use mouse to place them so I cant achieve this goal . Is this possible to do it via script? like create a vertex in position (1,1,0)??
Just to be sure, since you’re working in the Skinning Editor, is it for animation? Are you trying to create a custom shape? Or the auto-generated vertices are not aligned the way you want?
We currently don’t have Skinning Editor APIs that would allow you to set a custom outline in code.
If it’s the custom sprite outline that you are after, there is an API that you could use.
I want to create a character not an outline ,but size of the sprite is 8*8 ,( because of optimization)
so I want to create lots of vertices and bones inside this sprite,
but because of its size , I cant place vertices exactly at the positions I want cause I have to use mouse
I want to understand your particular use case better. What type of character are you creating? Have you tried auto-generating vertices with the Auto Geometry tool? Are they not aligned the way you need?
sorry I couldn’t tell you exactly what I want .I wrote this ,it creates some vertices and edges on the first pixel ,now my only problem is creating bones , Can you show me an example ?
using UnityEditor;
using UnityEngine;
using UnityEngine.U2D;
public class TestVertex : MonoBehaviour
{
public GameObject sprite;
void Start()
{
Sprite SSprite = gameObject.GetComponent<SpriteRenderer>().sprite;
var factory = new UnityEditor.U2D.Sprites.SpriteDataProviderFactories();
factory.Init();
var dataProvider = factory.GetSpriteEditorDataProviderFromObject(sprite);
dataProvider.InitSpriteEditorDataProvider();
{
var meshDP = dataProvider.GetDataProvider<UnityEditor.U2D.Sprites.ISpriteMeshDataProvider>();
int numVertices = 11;
UnityEditor.U2D.Sprites.Vertex2DMetaData[] vertData = new UnityEditor.U2D.Sprites.Vertex2DMetaData[numVertices];
var spRects = dataProvider.GetSpriteRects();
var spRect = spRects[0];
var spID = spRect.spriteID;
vertData[0] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.392f, 0.88f)
};
vertData[1] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.308f, 0.78f)
};
vertData[2] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.312f, 0.544f)
};
vertData[3] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.421f, 0.295f)
};
vertData[4] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.434f, 0.036f)
};
vertData[5] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.553f, 0.032f)
};
vertData[6] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.649f, 0.299f)
};
vertData[7] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.724f, 0.559f)
};
vertData[8] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.715f, 0.771f)
};
vertData[9] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.6208f, 0.9213f)
};
vertData[10] = new UnityEditor.U2D.Sprites.Vertex2DMetaData
{
position = new Vector2(0.472f, 0.9213f)
};
int[] indices = {
0,1,2,
0,2,3,
0,3,4,
0,4,5,
0,5,6,
0,6,7,
0,7,8,
0,8,9,
0,9,10
};
SpriteBone[] b = new SpriteBone[1];
SSprite.SetBones(b);
Vector2Int[] edges = new Vector2Int[11];
edges[0] = new Vector2Int(0, 1);
edges[1] = new Vector2Int(1, 2);
edges[2] = new Vector2Int(2, 3);
edges[3] = new Vector2Int(3, 4);
edges[4] = new Vector2Int(4, 5);
edges[5] = new Vector2Int(5, 6);
edges[6] = new Vector2Int(6, 7);
edges[7] = new Vector2Int(7, 8);
edges[8] = new Vector2Int(8, 9);
edges[9] = new Vector2Int(9, 10);
edges[10] = new Vector2Int(10, 0);
meshDP.SetVertices(spID, vertData);
meshDP.SetIndices(spID, indices);
meshDP.SetEdges(spID, edges);
}
dataProvider.Apply();
var assetImporter = dataProvider.targetObject as AssetImporter;
assetImporter.SaveAndReimport();
}
}
var boneDP = dataProvider.GetDataProvider<UnityEditor.U2D.Sprites.ISpriteBoneDataProvider>();
var newBones = new List<UnityEngine.U2D.SpriteBone>();
newBones.Add(new UnityEngine.U2D.SpriteBone
{
name = "bone_0",
position = new Vector3(0.001f, 0, 0),
rotation = Quaternion.identity,
length = 0f,
parentId = -1,
});
boneDP.SetBones(spID, newBones);