//キャラ描画 private void DrawChar() { Sprite sp = m_parent.GetSelectedSprite(); Vector2 pos = new Vector2(-sp.pivot.x, +sp.pivot.y - sp.rect.height); CharaCell cell = m_parent.GetSelectedCharCell(); //顔奥表示 if (cell.faceZ == 1) { DrawFace(pos, cell); } { //DebugPanel.Log("sp.rect", sp.rect); //Vector2 pos = new Vector2((1 * GRIDSIZE) + 0, (1 * GRIDSIZE) - 0); Vector2 size = new Vector2(sp.rect.width, sp.rect.height); Rect drawRect = new Rect((pos + m_camPos) * mag, size * mag); //DebugPanel.Log("drawRect", drawRect); //DebugPanel.Log("sp.pivot.", sp.pivot); if (sp != null) { GUI.DrawTextureWithTexCoords(drawRect, sp.texture, CharaCellEditorMain.GetSpriteNormalRect(sp)); //描画 } } //顔手前表示 if (cell.faceZ == 0) { DrawFace(pos, cell); } DrawGridLine3(); }
//顔描画 private void DrawFace(Vector2 pos, CharaCell cell) { const int BASEY = -32; float angle = cell.faceAngle * 90; Vector2 zuraRev = Vector2.zero; switch (cell.faceAngle) { case 0: angle = 0; zuraRev.y -= 1; break; case 1: zuraRev.x += 1; break; case 2: zuraRev.y += 1; break; case 3: zuraRev.x -= 1; break; } //顔 { Sprite kao = m_parent.GetSelectedKaoSprite(); Vector2 kaopos = new Vector2(-kao.pivot.x + cell.faceX, cell.faceY + BASEY); // kaopos += zuraRev; Vector2 size = new Vector2(kao.rect.width, kao.rect.height); Rect drawRect = new Rect((m_camPos + kaopos) * mag, size * mag); Vector2 rotatePivot = new Vector2(drawRect.center.x, drawRect.center.y - drawRect.height / 2); GUIUtility.RotateAroundPivot(angle, rotatePivot); // RotateAroundPivot等は行列の掛け算なので、一旦初期値に戻す GUI.DrawTextureWithTexCoords(drawRect, kao.texture, CharaCellEditorMain.GetSpriteNormalRect(kao)); //描画 GUI.matrix = Matrix4x4.identity; } //ずら { Sprite zura = m_parent.GetSelectedZuraSprite(); Vector2 zurapos = new Vector2(-zura.pivot.x + cell.faceX, cell.faceY + BASEY); zurapos += zuraRev; Vector2 size = new Vector2(zura.rect.width, zura.rect.height); Rect drawRect = new Rect((m_camPos + zurapos) * mag, size * mag); Vector2 rotatePivot = new Vector2(drawRect.center.x, drawRect.center.y - drawRect.height / 2); GUIUtility.RotateAroundPivot(angle, rotatePivot); // RotateAroundPivot等は行列の掛け算なので、一旦初期値に戻す GUI.DrawTextureWithTexCoords(drawRect, zura.texture, CharaCellEditorMain.GetSpriteNormalRect(zura)); //描画 GUI.matrix = Matrix4x4.identity; } }