public void DeselectPart(KitbashPart part) { if (part != null) { selectedParts.Remove(part); } }
public void SelectPart(KitbashPart part) { if (part != null) { selectedParts.Add(part); } }
public void AddPartToKitbash(string path) { importExport.ImportFromLibrary(path, false); currentImport.GO.transform.SetParent(transform); KitbashPart part = Instantiate(currentImport.GO.GetComponentInChildren <MeshRenderer>().gameObject).AddComponent <KitbashPart>(); part.transform.SetParent(kitbash.transform); part.rend = part.gameObject.GetComponent <MeshRenderer>(); part.rend.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; part.rend.receiveShadows = false; part.rend.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; Destroy(currentImport.GO); // part.gameObject.name.TrimEnd("(clone)".ToCharArray()); part.filter = part.gameObject.GetComponent <MeshFilter>(); part.original = part.filter.sharedMesh; part.col = part.gameObject.GetComponent <MeshCollider>(); part.col.sharedMesh = part.original; parts.Add(part); AddHierarchyItem(part); gizmo.transformType = TransformType.Move; gizmo.SetTranslatingAxis(TransformType.Move, RuntimeGizmos.Axis.Any); gizmo.AddTarget(part.gameObject.transform); }
//ui public void AddHierarchyItem(KitbashPart part) { /* GameObject go = Instantiate(hierarchyItem); * go.transform.SetParent(hierarchyContainer); * HierarchyItem item = go.GetComponent<HierarchyItem>(); * item.part = part; * item.buildControls = this; * item.SetText();*/ }
public void DestroySelected() { for (int i = selectedParts.Count - 1; i >= 0; i--) { KitbashPart part = selectedParts[i]; gizmo.RemoveTarget(selectedParts[i].transform); //TODO: remove hierarchy item. parts.Remove(part); Destroy(part.gameObject); } }
/// <summary> /// Combines mesh filters into a single mesh. /// </summary> /// <param name="filters"></param> public void CombineMeshes(List <MeshFilter> filters) { if (filters.Count > 1) { if (filters.Count > 0) { Mesh combine = MeshCombiner.MeshCombiner.Combine(filters.ToArray(), true, 0.01f); combine.Optimize(); combine.RecalculateBounds(); //Create part: GameObject go = new GameObject("Combined Part"); KitbashPart part = go.AddComponent <KitbashPart>(); //part.transform.SetParent(kitbash.transform); //Create renderer: part.rend = part.gameObject.AddComponent <MeshRenderer>(); part.rend.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; part.rend.receiveShadows = false; part.rend.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; //part.rend.material = defaultMat; part.rend.allowOcclusionWhenDynamic = false; //Assign mesh: part.filter = go.AddComponent <MeshFilter>(); part.filter.sharedMesh = combine; } else { Debug.LogError("No filters were added to combine!"); } } else { Debug.Log("Not enough filters to combine."); } }
//ui public void RemoveHierarchyItem(KitbashPart part) { }