本文整理汇总了C#中UnityEngine.Renderer.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.GetType方法的具体用法?C# Renderer.GetType怎么用?C# Renderer.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Renderer
的用法示例。
在下文中一共展示了Renderer.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectionsNode
static FbxNode ConnectionsNode (ref Mesh mesh, ref Renderer renderer) {
List<FbxNode> subnodes = new List<FbxNode>();
//string nodetext = "Connections: {\n";
//nodetext += "\tConnect: \"OO\", \"Model::" + mesh.name + "\", \"Model::Scene\"\n";
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Model::" + mesh.name + "\", \"Model::Scene\""));
foreach(Material mat in renderer.sharedMaterials){
// Skip if the material is not defined
if (mat==null) continue;
// Add the material connection
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Material::" + mat.name + "\", \"Model::" + mesh.name + "\""));
//nodetext += "\tConnect: \"OO\", \"Material::" + mat.name + "\", \"Model::" + mesh.name + "\"\n";
// Add textures
if (mat.HasProperty("_MainTex")){
//nodetext += "\tConnect: \"OO\", \"Texture::" + mat.name + "_diff" + "\", \"Model::" + mesh.name + "\"\n";
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Texture::" + mat.name + "_diff" + "\", \"Model::" + mesh.name + "\""));
}
if (mat.HasProperty("_BumpMap")){
//nodetext += "\tConnect: \"OO\", \"Texture::" + mat.name + "_bump" + "\", \"Model::" + mesh.name + "\"\n";
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Texture::" + mat.name + "_bump" + "\", \"Model::" + mesh.name + "\""));
}
}
if (renderer.GetType() == typeof(SkinnedMeshRenderer)){
SkinnedMeshRenderer skinnedrenderer = renderer as SkinnedMeshRenderer;
//nodetext += new FbxNode(1, "Connect", "\"OO\", \"Deformer::Skin " + mesh.name + "\", \"Model::" + mesh.name + "\"").ToString();
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Deformer::Skin " + mesh.name + "\", \"Model::" + mesh.name + "\""));
foreach (Transform bone in skinnedrenderer.bones){
//nodetext += new FbxNode(1, "Connect", "\"OO\", \"SubDeformer::Cluster " + mesh.name + " " + bone.name + "\", \"Deformer::Skin " + mesh.name + "\"").ToString();
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"SubDeformer::Cluster " + mesh.name + " " + bone.name + "\", \"Deformer::Skin " + mesh.name + "\""));
}
foreach (Transform bone in skinnedrenderer.bones){
//nodetext += new FbxNode(1, "Connect", "\"OO\", \"Model::" + bone.name + "\", \"SubDeformer::Cluster " + mesh.name + " " + bone.name + "\"").ToString();
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Model::" + bone.name + "\", \"SubDeformer::Cluster " + mesh.name + " " + bone.name + "\""));
}
// Add the heiarchy of models
List<Transform> boneList = skinnedrenderer.bones.ToList();
while (boneList.Count > 0){
for (int i=0;i<boneList.Count;i++){
Transform parent = boneList[i].parent;
if (!boneList.Contains(parent)){
if (System.Array.Exists(skinnedrenderer.bones, p=>p==parent)){
//nodetext += new FbxNode(1, "Connect", "\"OO\", \"Model::" + boneList[i].name + "\", \"Model::" + parent.name + "\"").ToString();
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Model::" + boneList[i].name + "\", \"Model::" + parent.name + "\""));
} else {
//nodetext += new FbxNode(1, "Connect", "\"OO\", \"Model::" + boneList[i].name + "\", \"Model::Scene\"").ToString();
subnodes.Add(new FbxNode(1, "Connect", "\"OO\", \"Model::" + boneList[i].name + "\", \"Model::Scene\""));
}
boneList.RemoveAt(i);
}
}
}
}
//nodetext += "}";
//return nodetext;
return new FbxContainerNode(0, "Connections", "", subnodes.ToArray());
}
示例2: ExportToString
public static string ExportToString (Mesh mesh, ref Renderer renderer, bool uselhcoords = true){
#if UNITY_EDITOR
EditorUtility.DisplayProgressBar("EJM Software FBX Exporter", "Writing header", 0f);
#endif
string documenttext = "; FBX 6.1.0 project file\n; Copyright (C) 1997-2008 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n";
documenttext += FBXHeaderExtensionNode ();
documenttext += "\n\n; Object definitions\n;------------------------------------------------------------------\n\n";
documenttext += DefinitionsNode (ref mesh, ref renderer).ToString();
documenttext += "\n\n; Object properties\n;------------------------------------------------------------------\n\n";
string skinmodelnodes = "", defnodes = "", posenode = "";
if (renderer.GetType() == typeof(SkinnedMeshRenderer)){
#if UNITY_EDITOR
EditorUtility.DisplayProgressBar("EJM Software FBX Exporter", "Parsing skinning data", 0.33f);
#endif
SkinnedMeshRenderer skmr = renderer as SkinnedMeshRenderer;
skinmodelnodes = SkinnedModelNodes(ref skmr);
defnodes = DeformationNodes(ref mesh, ref skmr);
posenode = PoseNode(ref mesh);
}
#if UNITY_EDITOR
EditorUtility.DisplayProgressBar("EJM Software FBX Exporter", "Writing mesh data", 0.66f);
#endif
documenttext += ObjectsNode (ModelNodes (ref mesh, uselhcoords) + skinmodelnodes, MaterialNodes (ref renderer), TextureNodes(ref renderer), defnodes, posenode, GlobalSettingsNode ().ToString());
documenttext += "\n\n; Object connections\n;------------------------------------------------------------------\n\n";
documenttext += ConnectionsNode (ref mesh, ref renderer).ToString();
documenttext += "\n\n;Version 5 settings\n;------------------------------------------------------------------\n\n";
documenttext += Version5Node ();
#if UNITY_EDITOR
EditorUtility.ClearProgressBar();
#endif
return documenttext;
}
示例3: DefinitionsNode
static FbxNode DefinitionsNode (ref Mesh mesh, ref Renderer renderer) {
// calculate the number of subnodes needed
int subnodecount = 6;
if (renderer.GetType() == typeof(SkinnedMeshRenderer)){
subnodecount += 2;
}
// calculate the counts
int ModelCount = 1;
int MatCount = MaterialNodeCount (ref renderer);
int TexCount = TextureNodeCount (ref renderer);
// create the node
FbxContainerNode node = new FbxContainerNode(0, "Definitions", "", new FbxNode[subnodecount]);
node.subnodes[0] = new FbxNode(1, "Version", "100");
node.subnodes[1] = new FbxNode(1, "Count", (ModelCount + MatCount + TexCount + 1).ToString());
node.subnodes[2] = new FbxContainerNode(2, "ObjectType", "\"Model\"", new FbxNode[1]{new FbxNode(3, "Count", ModelCount.ToString())});
node.subnodes[3] = new FbxContainerNode(2, "ObjectType", "\"Material\"", new FbxNode[1]{new FbxNode(3, "Count", MatCount.ToString())});
node.subnodes[4] = new FbxContainerNode(2, "ObjectType", "\"Texture\"", new FbxNode[1]{new FbxNode(3, "Count", TexCount.ToString())});
if (renderer.GetType() == typeof(SkinnedMeshRenderer)){
SkinnedMeshRenderer skinnedrenderer = renderer as SkinnedMeshRenderer;
node.subnodes[5] = new FbxContainerNode(2, "ObjectType", "\"Deformer\"", new FbxNode[1]{new FbxNode(3, "Count", skinnedrenderer.bones.Length.ToString())});
node.subnodes[6] = new FbxContainerNode(2, "ObjectType", "\"Pose\"", new FbxNode[1]{new FbxNode(3, "Count", "1")});
}
node.subnodes[subnodecount - 1] = new FbxContainerNode(2, "ObjectType", "\"GlobalSettings\"", new FbxNode[1]{new FbxNode(3, "Count", "1")});// There is always 1 global settings node
return node;
}