Esempio n. 1
0
    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;
        }
    }
Esempio n. 2
0
 public void AssignScripts(CuttingObject co)
 {
     cuttingGameObject = co;
     foreach (Transform child in transform)
     {
         child.gameObject.AddComponent <ObjectToCut>();
         child.gameObject.GetComponent <ObjectToCut>().AssignScripts(co);
     }
 }
Esempio n. 3
0
 public void Notify(CuttingObject cutObjCont)
 {
     if (cuttingGameObject == cutObjCont)
     {
         ReadCuttingObjectProperties();
     }
     else
     {
         cutObjCont.Unsubscribe(this);
     }
 }
Esempio n. 4
0
    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>());
        }
    }