Exemplo n.º 1
0
    public void setTone()
    {
        hypercubeCanvas c = hypercube.GetComponent <hypercubeCamera>().localCanvas;

        if (c)
        {
            c.setTone(toneSlider.value);
        }
    }
    void Start()
    {
        if (!localCanvas)
        {
            localCanvas = GameObject.FindObjectOfType <hypercubeCanvas>();
            if (!localCanvas)
            {
                //if no canvas exists. we need to have one or the hypercube is useless.
#if UNITY_EDITOR
                localCanvas = UnityEditor.PrefabUtility.InstantiatePrefab(canvasPrefab) as hypercubeCanvas; //try to keep the prefab connection, if possible
#else
                localCanvas = Instantiate(canvasPrefab);                                                    //normal instantiation, lost the prefab connection
#endif
            }
        }

        //use our save values only in the player only to avoid confusing behaviors in the editor
        //LOAD OUR PREFS
        if (!Application.isEditor)
        {
            dataFileAssoc d = GetComponent <dataFileAssoc>();
            if (d)
            {
                slices = d.getValueAsInt("sliceCount", 10);
                localCanvas.sliceOffsetX = d.getValueAsFloat("offsetX", 0);
                localCanvas.sliceOffsetY = d.getValueAsFloat("offsetY", 0);
                localCanvas.sliceWidth   = d.getValueAsFloat("sliceWidth", 800f);
                localCanvas.sliceHeight  = d.getValueAsFloat("pixelsPerSlice", 68f);
                localCanvas.flipX        = d.getValueAsBool("flipX", false);
                overlap       = d.getValueAsFloat("overlap", .15f);
                useSoftSlices = d.getValueAsBool("useSoftSlices", true);
            }
        }

        localCanvas.updateMesh(slices);
        resetSettings();
        updateOverlap();
    }