protected virtual void TryCreateWireframe(ExposeToEditor obj) { PBMesh pbMesh = obj.GetComponent <PBMesh>(); if (pbMesh != null && !pbMesh.GetComponentsInChildren <WireframeMesh>().Any(w => !w.IsIndividual)) { CreateWireframeMesh(pbMesh); } }
private void OnObjectStarted(ExposeToEditor obj) { PBMesh pbMesh = obj.GetComponent <PBMesh>(); if (pbMesh != null) { CreateWireframeMesh(pbMesh); } }
public PBMesh ProBuilderize(GameObject gameObject, bool hierarchy, Vector2 uvScale) { bool wasActive = false; if (uvScale != Vector2.one) { wasActive = gameObject.activeSelf; gameObject.SetActive(false); } if (hierarchy) { MeshFilter[] meshFilters = gameObject.GetComponentsInChildren <MeshFilter>(true); for (int i = 0; i < meshFilters.Length; ++i) { if (meshFilters[i].GetComponent <PBMesh>() == null) { ExposeToEditor exposeToEditor = meshFilters[i].GetComponent <ExposeToEditor>(); if (exposeToEditor != null) { exposeToEditor.AddComponent(typeof(PBMesh)); PBMesh pbMesh = exposeToEditor.GetComponent <PBMesh>(); PBMesh.Init(pbMesh, uvScale); } } } if (uvScale != Vector2.one) { gameObject.SetActive(wasActive); } return(gameObject.GetComponent <PBMesh>()); } else { PBMesh mesh = gameObject.GetComponent <PBMesh>(); if (mesh != null) { if (uvScale != Vector2.one) { gameObject.SetActive(wasActive); } return(mesh); } mesh = gameObject.AddComponent <PBMesh>(); PBMesh.Init(mesh, uvScale); if (uvScale != Vector2.one) { gameObject.SetActive(wasActive); } return(mesh); } }
public void OnUnselected(ExposeToEditor obj) { Rigidbody rig = obj.GetComponent <Rigidbody>(); if (rig) { rig.isKinematic = true; } CubemanCharacter cubeman = obj.GetComponent <CubemanCharacter>(); if (cubeman != null) { cubeman.Move(Vector3.zero, false, false); cubeman.Enabled = false; } CubemanUserControl userCtrl = obj.GetComponent <CubemanUserControl>(); if (userCtrl != null) { userCtrl.HandleInput = false; } }
protected virtual void TryDestroyWireframe(ExposeToEditor obj) { PBMesh pbMesh = obj.GetComponent <PBMesh>(); if (pbMesh != null) { WireframeMesh[] wireframeMesh = pbMesh.GetComponentsInChildren <WireframeMesh>(true); for (int i = 0; i < wireframeMesh.Length; ++i) { WireframeMesh wireframe = wireframeMesh[i]; if (!wireframe.IsIndividual) { Destroy(wireframe.gameObject); break; } } } }