private void OnPBMeshChanged(bool positionsOnly) { if (m_update) { m_pbMesh.BuildEdgeMesh(m_filter.sharedMesh, m_color, positionsOnly); } }
private void OnPBMeshChanged(bool positionsOnly, bool forceUpdate) { if (m_update || forceUpdate) { m_pbMesh.BuildEdgeMesh(m_filter.sharedMesh, IsSelected ? m_selectionColor : m_color, positionsOnly); TryUpdateColorCache(); } }
private void Awake() { m_color = new Color(Random.value, Random.value, Random.value); m_filter = GetComponent <MeshFilter>(); if (!m_filter) { m_filter = gameObject.AddComponent <MeshFilter>(); } if (!m_filter.sharedMesh) { m_filter.sharedMesh = new Mesh(); } MeshRenderer renderer = GetComponent <MeshRenderer>(); if (renderer == null) { renderer = gameObject.AddComponent <MeshRenderer>(); } renderer.sharedMaterial = PBBuiltinMaterials.LinesMaterial; renderer.sharedMaterial.SetColor("_Color", Color.white); renderer.sharedMaterial.SetInt("_HandleZTest", (int)CompareFunction.LessEqual); renderer.sharedMaterial.SetFloat("_Scale", 0.5f); m_pbMesh = GetComponentInParent <PBMesh>(); m_pbMesh.Selected += OnPBMeshSelected; m_pbMesh.Changed += OnPBMeshChanged; m_pbMesh.Unselected += OnPBMeshUnselected; m_pbMesh.BuildEdgeMesh(m_filter.sharedMesh, m_color, false); }
private void Awake() { m_pbMesh = GetComponentInParent <PBMesh>(); m_pbMesh.Selected += OnPBMeshSelected; m_pbMesh.Changed += OnPBMeshChanged; m_pbMesh.Unselected += OnPBMeshUnselected; int instanceId = Mathf.Abs(BitConverter.ToInt32(s_hashAlgo.ComputeHash(BitConverter.GetBytes(m_pbMesh.GetInstanceID())), 0)); Color32[] colors = Colors.Kellys; m_color = colors[instanceId % colors.Length]; m_filter = GetComponent <MeshFilter>(); if (!m_filter) { m_filter = gameObject.AddComponent <MeshFilter>(); } if (!m_filter.sharedMesh) { m_filter.sharedMesh = new Mesh(); } MeshRenderer renderer = GetComponent <MeshRenderer>(); if (renderer == null) { renderer = gameObject.AddComponent <MeshRenderer>(); } renderer.sharedMaterial = PBBuiltinMaterials.LinesMaterial; renderer.sharedMaterial.SetColor("_Color", Color.white); renderer.sharedMaterial.SetInt("_HandleZTest", (int)CompareFunction.LessEqual); renderer.sharedMaterial.SetFloat("_Scale", 0.5f); m_pbMesh.BuildEdgeMesh(m_filter.sharedMesh, IsSelected ? m_selectionColor : m_color, false); UpdateColorCache(); }