private void ReadCuttingObjectProperties() { if (cuttingGameObject == null) { stop = true; return; } stop = !cuttingGameObject.enabled || !(Application.isPlaying || cuttingGameObject.cutInEditMode) || cuttingGameObject.cutType == CutType.None; normal = cuttingGameObject.transform.TransformVector(new Vector3(0, 0, -1)); position = cuttingGameObject.transform.position; cuttingGameObject = cuttingGameObject.GetComponent <CuttingObject>(); cuttingGameObject.Subscribe(this); cutType = cuttingGameObject.cutType; if (cutType == CutType.Sphere) { sphereRadius = cuttingGameObject.sphereRadius; } }
public void AssignScripts(CuttingObject co) { cuttingGameObject = co; foreach (Transform child in transform) { child.gameObject.AddComponent <ObjectToCut>(); child.gameObject.GetComponent <ObjectToCut>().AssignScripts(co); } }
public void Notify(CuttingObject cutObjCont) { if (cuttingGameObject == cutObjCont) { ReadCuttingObjectProperties(); } else { cutObjCont.Unsubscribe(this); } }
public void RemoveScripts() { foreach (Transform child in transform) { child.gameObject.GetComponent <ObjectToCut>().RemoveScripts(); } if (oldShader != Shader.Find("GenericCrossSection/GenericShader")) { rend.sharedMaterial.shader = oldShader; } cuttingGameObject = null; if (Application.isEditor) { DestroyImmediate(GetComponent <ObjectToCut>()); } else { Destroy(GetComponent <ObjectToCut>()); } }