Unity 笔记
笔记 Unity
2023-09-27 14:25:33 时间
复数
https://zhuanlan.zhihu.com/p/87793349
四元数
https://blog.csdn.net/candycat1992/article/details/41254799
https://www.cnblogs.com/leixinyue/p/13469155.html
在Unity中程序化生成的地牢环境
https://www.gameres.com/860585.html
Bowyer-Watson算法
using System.IO;
using UnityEditor;
using UnityEngine;
public class ReplaceDDS : Editor {
[MenuItem("Tools/Replace DDS Texture")]
public static void ToChangeMaterialsDDS () {
string[] paths = AssetDatabase.GetAllAssetPaths();
for (int i = 0; i < paths.Length; i++) {
string path = paths[i];
if (string.IsNullOrEmpty(path)) continue;
if (path.IndexOf("Assets/") < 0) continue;
string extension = Path.GetExtension(path).ToLower();
if(extension == ".png") {
// Debug.Log(path);
}
if (extension == ".fbx") {
Object[] objects = AssetDatabase.LoadAllAssetRepresentationsAtPath(paths[i]);
for (int j = 0; j < objects.Length; j++) {
Object obj = objects[j];
if (obj && obj is Material) {
ReplaceMaterialDDS((Material)obj);
}
}
} else {
Material material = AssetDatabase.LoadAssetAtPath<Material>(path);
if (material) {
ReplaceMaterialDDS(material);
}
}
}
//保存并刷新资源
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
EditorUtility.DisplayDialog("Complete", "Replace DDS texture complete", "OK");
}
public static void ReplaceMaterialDDS (Material material) {
string[] propertyNames = { "_MainTex", "_BumpMap" };
for (int i = 0; i < propertyNames.Length; i++) {
string propertyName = propertyNames[i];
Texture texture = material.GetTexture(propertyName);
if (texture) {
string texturePath = AssetDatabase.GetAssetPath(texture);
string texturePathExtension = Path.GetExtension(texturePath).ToLower();
if (texturePathExtension == ".dds") {
string newTextruePath = texturePath.Substring(0, texturePath.Length - texturePathExtension.Length) + ".png";
Texture newTexture = AssetDatabase.LoadAssetAtPath<Texture>(newTextruePath);
if (newTexture) {
material.SetTexture(propertyName, newTexture);
}
}
}
}
}
}
相关文章
- 009_【OS X和iOS系统学习笔记】 OS X架构
- MySQL学习笔记_1_MySQL数据库管理系统概述
- [论文笔记]Cascade RCNN 阅读笔记
- UCOS-信号标志组(学习笔记)
- 【Android开发笔记】android studio 更新指定的 android sdk and java sdk (待补充)
- VNote: 一个舒适的Markdown笔记软件
- ROS学习笔记—-- catkin
- Cocos2d-x学习笔记(五岁以下儿童) 精灵两种方式播放动画
- Unity UI Toolkit学习笔记-Runtime UI 案例实践
- Unity特效学习笔记_豪火球之术
- Unity ECS 案例学习笔记
- Unity特效学习笔记_文明之火
- Unity学习笔记--unity中使用ShaderGraphs制作海水UV动画效果
- 读经典——《CLR via C#》(Jeffrey Richter著) 笔记_new新建对象
- 【Darwin学习笔记】之获取系统处理器数量的方法
- SDL2.0 学习笔记-1 windows下的第一个测试程序
- React.js学习笔记