public void CreateMeshAnimator(GameObject obj) { MeshFilter meshFilter = obj.GetComponent <MeshFilter>(); if (meshFilter == null) { meshFilter = obj.AddComponent <MeshFilter>(); #if UNITY_EDITOR GameObject tempSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); meshFilter.sharedMesh = tempSphere.GetComponent <MeshFilter>().sharedMesh; DestroyImmediate(tempSphere); #endif } ; MeshRenderer meshRenderer = obj.GetComponent <MeshRenderer>(); if (meshRenderer == null) { meshRenderer = obj.AddComponent <MeshRenderer>(); meshRenderer.material = new Material(Shader.Find("Standard")); } MeshAnimator meshAnimator = obj.GetComponent <MeshAnimator>(); if (meshAnimator == null) { meshAnimator = obj.AddComponent <MeshAnimator>(); } //meshAnimator.LoadFromFolder(); LoadFromFolder(meshAnimator); //return meshAnimator; }
public void LoadFromFolder(MeshAnimator meshAnimator) { if (tools.Message("Load Baked Animation In Folder", "Select one of the models in the folder you wish to load.", "OK", "Cancel")) { //EditorGUIUtility.ShowObjectPicker<GameObject>(null, false, "", GetInstanceID()); currentAnimator = meshAnimator; showPicker = true; } else { Close(); } }
void OnEnable() { if (tools == null) { tools = new EditorTools("MeshAnimator_Editor", this); } if (animator == null) { animator = (MeshAnimator)target; } if (objectPickerID == 0) { objectPickerID = this.GetInstanceID() + 1; } }
public MeshAnimator CreateMeshAnimator(GameObject obj, MeshAnimator animator) { MeshFilter meshFilter = obj.GetComponent <MeshFilter>(); if (meshFilter == null) { meshFilter = obj.AddComponent <MeshFilter>(); MeshFilter existingMeshFilter = animator.GetComponent <MeshFilter>(); if (existingMeshFilter != null) { meshFilter.sharedMesh = existingMeshFilter.sharedMesh; } } MeshRenderer meshRenderer = obj.GetComponent <MeshRenderer>(); if (meshRenderer == null) { meshRenderer = obj.AddComponent <MeshRenderer>(); MeshRenderer existingRenderer = animator.GetComponent <MeshRenderer>(); if (existingRenderer != null) { meshRenderer.sharedMaterial = existingRenderer.sharedMaterial; } } MeshAnimator meshAnimator = obj.GetComponent <MeshAnimator>(); if (meshAnimator == null) { meshAnimator = obj.AddComponent <MeshAnimator>(); } meshAnimator.LoadFromAnimator(animator); return(meshAnimator); }
public void LoadFromAnimator(MeshAnimator other) { meshes.Clear(); models.Clear(); modelMeshFilters.Clear(); meshes.AddRange(other.meshes); models.AddRange(other.models); modelMeshFilters.AddRange(other.modelMeshFilters); meshFilterType = other.meshFilterType; meshNameFilter = other.meshNameFilter; modelFilterType = other.modelFilterType; modelNameFilter = other.modelNameFilter; autoSortModels = other.autoSortModels; currentMeshIndex = other.currentMeshIndex; framerate = other.framerate; direction = other.direction; playback = other.playback; frameInterval = other.frameInterval; frameIntervalCounter = other.frameIntervalCounter; paused = other.paused; }