private VisualPartRuntime Instantiate() { string newName = string.Format("New Visual Part {0}", _internalCounter); _internalCounter++; return(VisualPartRuntime.Create(transform, newName)); }
public void GenerateRuntimeMesh() { HUtils.log(); // Debug.Log("GenerateRuntimeMesh"); if (!isLegal) { Debug.LogWarning("Illegal Runtime Volume. Base points likely intersect"); for (int p = 0; p < numberOfPoints; p++) { Debug.Log(this[p].position.vector3XY); } } if (visualPart == null) { _visualPart = VisualPartRuntime.GetPoolItem(); } _visualPart.GenerateFromDynamicMesh(); for (int f = 0; f < _interiorFloorplans.Count; f++) { _interiorFloorplans[f].GenerateRuntimeMesh(); _interiorFloorplans[f].transform.parent = transform; _interiorFloorplans[f].transform.localPosition = Vector3.zero; } }
public void GenerateRuntimeMesh() { if (visualPart == null) { _visualPart = VisualPartRuntime.GetPoolItem(); } _visualPart.GenerateFromDynamicMesh(); }
public void Clear() { if (_visualPart != null) { _visualPart.Deactivate(); VisualPartRuntimePool.Instance.Push(_visualPart); } _visualPart = null; }
public void Push(VisualPartRuntime item) { if (!_initialised) { Init(); } item.transform.parent = transform; _pool.Add(item); }
public VisualPartRuntime Pull() { if (!_initialised) { Init(); } VisualPartRuntime output = GetPoolItem(); output.Activate(); return(output); }
public void GenerateFromDynamicMesh(BuildRMesh overflow = null) { HUtils.log(); if (_dynamicMesh.vertexCount == 0) { return; } if (_mesh == null) { _mesh = new Mesh(); } if (_filter == null) { _filter = gameObject.AddComponent <MeshFilter>(); } if (_renderer == null) { _renderer = gameObject.AddComponent <MeshRenderer>(); } if (overflow != null) { _dynamicMesh = overflow; } _dynamicMesh.Build(_mesh); _filter.sharedMesh = _mesh; _renderer.sharedMaterials = _dynamicMesh.materials.ToArray(); if (_dynamicMesh.hasOverflowed) { if (_sibling == null) { _sibling = GetPoolItem(); } _sibling.GenerateFromDynamicMesh(_dynamicMesh.overflow); } else { if (_sibling != null) { _sibling.Deactivate(); VisualPartRuntimePool.Instance.Push(_sibling); } _sibling = null; } if (_colliderPart == null) { _colliderPart = ColliderPartRuntime.GetPoolItem(); _colliderPart.GenerateFromColliderMesh(_colliderMesh); } }
private VisualPartRuntime GetPoolItem() { if (_pool.Count > 0) { VisualPartRuntime output = _pool[0]; _pool.RemoveAt(0); return(output); } else { return(Instantiate()); //there was nothing suitable in the pool - make a new one! } }
public void Clear() { if (_visualPart != null) { _visualPart.Deactivate(); VisualPartRuntimePool.Instance.Push(_visualPart); } _visualPart = null; for (int f = 0; f < _interiorFloorplans.Count; f++) { _interiorFloorplans[f].Clear(); } _interiorFloorplans.Clear(); }
public static VisualPartRuntime Create(Transform parent = null, string name = "visual part") { HUtils.log(); GameObject go = new GameObject(name); if (parent != null) { go.transform.parent = parent; } VisualPartRuntime output = go.AddComponent <VisualPartRuntime>(); output.Init(); output.Deactivate(); return(output); }
public void Deactivate() { HUtils.log(); _filter.sharedMesh = null; _renderer.sharedMaterials = new Material[0]; _renderer.enabled = false; _mesh.Clear(false); _mesh = null; if (_sibling != null) { _sibling.Deactivate(); VisualPartRuntimePool.Instance.Push(_sibling); _sibling = null; } }