private void FixRenderers() { var isNpc = !this.Tid.Contains("rda"); var renderers = this.Target.GetComponentsInChildren <SkinnedMeshRenderer>(true); foreach (var r in renderers) { if (cm.MainScene) { r.updateWhenOffscreen = false; if (isNpc) { Debug.Log("npc update aabb:" + this.Tid); var so = new SerializedObject(r); var property = so.FindProperty("m_DirtyAABB"); property.boolValue = true; property = so.FindProperty("m_AABB.m_Center"); property.vector3Value = Vector3.zero; property = so.FindProperty("m_AABB.m_Extent"); property.vector3Value = Vector3.zero; so.ApplyModifiedProperties(); } } else { r.updateWhenOffscreen = false; } r.receiveShadows = false; r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; r.motionVectors = false; r.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; r.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; r.skinnedMotionVectors = false; if (Tid.Contains("npc999")) { r.quality = SkinQuality.Bone1; } else { r.quality = SkinQuality.Auto; } } }
public void Setup(bool stripMesh = true, bool stripAvatar = true, bool makeControllerHolder = true, bool combineMesh = true) { var template = GetTemplate(); if (!Tid.Contains("npc999")) { AddColliders(template); } AddBehaviours(template); GameObject.DestroyImmediate(template); if (stripMesh) { StripMesh(); } if (stripAvatar) { StripAvatar(); } if (makeControllerHolder) { MakeControllerHolder(); } FixRenderers(); if (!cm.MainScene) { CreateDefaultParts(); } if (combineMesh) { CombineMesh(); } Save(); }
public void Save() { var go = this.Target; this.Animator.enabled = true; if (Tid.Contains("npc999")) { if (this.Animator.isOptimizable) { //AnimatorUtility.OptimizeTransformHierarchy(go, new string[] { }); } } if (cm.MainScene && this.Animator.isOptimizable) { AnimatorUtility.OptimizeTransformHierarchy(go, exposedBones); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; } var prefabPath = GetPrefabPath(); Directory.CreateDirectory(Path.GetDirectoryName(prefabPath)); var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath); if (prefab == null) { LogUtil.Debug("create prefab " + prefabPath); PrefabUtility.CreatePrefab(prefabPath, go, ReplacePrefabOptions.ConnectToPrefab); } else { LogUtil.Debug("replace prefab " + prefabPath); PrefabUtility.ReplacePrefab(go, prefab, ReplacePrefabOptions.ReplaceNameBased); EditorUtility.SetDirty(prefab); } }