当前位置:首页 » 激光切割 » unity怎么切割图片

unity怎么切割图片

发布时间: 2021-02-21 02:55:36

Ⅰ 有酬劳,写一个unity3d可使用的C#方法,按照模板动态切割图片

这个好像有点难哦, 模版是什么文件类型, 是一个图片吗? 请嫁我口扣:肆吴吧无四令零思吾

Ⅱ Unity3d 如何将Game试图中所呈现的3d物体截取成图片,并保存,显示在GUI上

使用函数 :

Application.CaptureScreenshot

有2个重载,使用第一个就好
static function CaptureScreenshot (filename : String) : void

static function CaptureScreenshot (filename : String, superSize : int = 0) : void

注:在web player下此函数不版工作~权~

Ⅲ unity sprite怎么获取切割后的图

假设有一张png/tga图集,导入到Unity,放置目录"Assets/Resources/UI"(UI文件夹可替换成其他的,重要的是要在"Assets/Resources/"路径下),

为了可以使用Unity自带的精灵切割,要将纹理类型改成"Sprite","Sprite Mode"改成"Multiple","Format"改成"Truecolor",点击"Apply"按钮进行应用。
接着,点击"Sprite Editor"打开精灵编辑器,点击左上角的"Slice"按钮,弹出切片设置,再次点击里面的"Slice"按钮,就会自动对图片进行切割
在对切割不完整的地方进行修正后,点击右上角的"Apply"按钮,进行保存。可以看到Project视图下这个图集,已经被分割出许多小图了
接下来,因为要对图片进行读写操作,要更改图片的属性才能进行,否则会提示如下:
UnityException: Texture 'testUI' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
将图片纹理类型更改为"Advanced",将"Read/Write Enabled"属性进行打勾,如下图所示:
创建一个脚本文件,代码如下:
using UnityEngine;
using UnityEditor;
public class TestSaveSprite
{
(MenuItem("Tools/导出精灵"))
static void SaveSprite()
{
string resourcesPath = "Assets/Resources/";
foreach (Object obj in Selection.objects)
{
string selectionPath = AssetDatabase.GetAssetPath(obj);
// 必须最上级是"Assets/Resources/"
if (selectionPath.StartsWith(resourcesPath))
{
string selectionExt = System.IO.Path.GetExtension(selectionPath);
if (selectionExt.Length == 0)
{
continue;
}
// 从路径"Assets/Resources/UI/testUI.png"得到路径"UI/testUI"
string loadPath = selectionPath.Remove(selectionPath.Length - selectionExt.Length);
loadPath = loadPath.Substring(resourcesPath.Length);
// 加载此文件下的所有资源
Sprite()sprites = Resources.LoadAll<Sprite>(loadPath);
if (sprites.Length > 0)
{
// 创建导出文件夹
string outPath = Application.dataPath + "/outSprite/" + loadPath;
System.IO.Directory.CreateDirectory(outPath);
foreach (Sprite sprite in sprites)
{
// 创建单独的纹理
Texture2D tex = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height, sprite.texture.format, false);
tex.SetPixels(sprite.texture.GetPixels((int)sprite.rect.xMin, (int)sprite.rect.yMin,
(int)sprite.rect.width, (int)sprite.rect.height));
tex.Apply();
// 写入成PNG文件
System.IO.File.WriteAllBytes(outPath + "/" + sprite.name + ".png", tex.EncodeToPNG());
}
Debug.Log("SaveSprite to " + outPath);
}
}
}
Debug.Log("SaveSprite Finished");
}
}
在Unity编辑器将会看到Tools菜单下多了"导出精灵"项,选中图集,然后点击"导出精灵"菜单项,即可导出子图成功。

Ⅳ unity3d的ugui怎么切图

Create games in the way of samurai. 将图片边界设大一个像素。 如果用的是类似TexturePacker的工具可以将extrude设为1。 这样就可以避免黑线问题。

Ⅳ Unity怎么在脚本中分割精灵图集,不是在SpriteEditor里

你可以使用Rigidbody2D来实现 AddForce 然后ForceMode中找到Impulse的枚举值
你也可以使用CharacterController的来进行,操作但是这个回类并没有重力答功能,需要你自己实现从起跳到落地时角色运动的轨迹

Ⅵ 想问问,unity17.1里,用sprite editor切割图时,slice是灰色用不了,怎么办啊

你图片的模式对不对 如果是上面那个的话是九宫格拉伸模式 下面这个才能用来切片

Ⅶ 如何在Unity中截图

据我所知,可以用下面的方法:
1 内置方法(简单有效,但是貌似不能够自定义存储路径等等):
Application.CaptureScreenshot ("Screenshot.png");
2 自己写一个方法读点(用的是类似流的思路还算比较灵活,但是存大图会卡,推荐图像类型慎重选择)

IEnumerator OnScreenCapture ()
{
yield return new WaitForEndOfFrame();//等待这一帧画完了才能截图
try
{
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D ( width, height, TextureFormat.RGB24, false);//新建一张图
tex.ReadPixels (new Rect (0, 0, width, height), 0, 0, true);//从屏幕开始读点
byte[] imagebytes = tex.EncodeToJPG ();//用的是JPG(这种比较小)
//使用它压缩实时产生的纹理,压缩过的纹理使用更少的显存并可以更快的被渲染
//通过true为highQuality参数将抖动压缩期间源纹理,这有助于减少压缩伪像
//因为压缩后的图像不作为纹理使用,只是一张用于展示的图
//但稍微慢一些这个小功能暂时貌似还用不到
tex.Compress (false);
tex.Apply();
Texture2D mScreenShotImgae = tex;
File.WriteAllBytes ( @"E:\Screenshot.png", imagebytes);

}
catch (System.Exception e)
{
Debug.Log ("ScreenCaptrueError:" + e);
}

}

Ⅷ Unity3d中的几种截图方法

很抱歉所知甚少,目前我仅知道两种截图方式“
第一种,用自带的API来做,灵活性一般:Application.CaptureScreenshot ("Screenshot.png");
第二种,读屏幕的图像并保存,需要在协程里面等待一帧,示例如下:
IEnumerator OnScreenCapture ()

{
yield return new WaitForEndOfFrame();//等待这一帧画完了才能截图
try
{
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D ( width, height, TextureFormat.RGB24, false);//新建一张图
tex.ReadPixels (new Rect (0, 0, width, height), 0, 0, true);//从屏幕开始读点
byte[] imagebytes = tex.EncodeToJPG ();//用的是JPG(这种比较小)
tex.Compress (false);
tex.Apply();
Texture2D mScreenShotImgae = tex;
File.WriteAllBytes ( @"E:\Screenshot.png", imagebytes);
}
catch (System.Exception e)
{
Debug.Log ("ScreenCaptrueError:" + e);
}
}
如果有路过的大神知道其他的截图方法,请一定要告知我,万分感谢。

Ⅸ Unity能否进行图片的不规则切割

用polygon collider

Ⅹ unity3d 怎么对贴图进行裁切

您好 max的模型抄导入Unity3d里面,导入的时候只是导入模型而已。 至于把贴图也导入的话,您可以试试把模型导出为FBX的格式,然后再把贴图文件和FBX的模型文件放到同一个文件夹中,然后扔到Unity3D里头就可以了。贴图的名字不要有中文,不然Unity。

热点内容
线切割怎么导图 发布:2021-03-15 14:26:06 浏览:709
1台皮秒机器多少钱 发布:2021-03-15 14:25:49 浏览:623
焊接法兰如何根据口径配螺栓 发布:2021-03-15 14:24:39 浏览:883
印章雕刻机小型多少钱 发布:2021-03-15 14:22:33 浏览:395
切割机三五零木工貝片多少钱 发布:2021-03-15 14:22:30 浏览:432
加工盗砖片什么榉好 发布:2021-03-15 14:16:57 浏览:320
北洋机器局制造的银元什么样 发布:2021-03-15 14:16:52 浏览:662
未来小七机器人怎么更新 发布:2021-03-15 14:16:33 浏览:622
rexroth加工中心乱刀怎么自动调整 发布:2021-03-15 14:15:05 浏览:450
机械键盘的键帽怎么选 发布:2021-03-15 14:15:02 浏览:506