예제 #1
0
    void OnEnable()
    {
        //Prevent OnInspectorGUI from running before these functions have been called
        isReady = false;

        SetStyling();

        selected = Selection.activeGameObject;

        if (!selected)
        {
            return;
        }

        if (!stylizedWater)
        {
            stylizedWater = selected.GetComponent <StylizedWater>();
        }

        serializedObject = new SerializedObject(stylizedWater);

        stylizedWater.Init();

        GetProperties();

        isWaterLayer.boolValue = (selected.gameObject.layer == 4) ? true : false;

        EditorUtility.SetDirty(target);

        isReady = true;
    }
    //Saving meta data
    private void setScriptValues(StylizedWater sws)
    {
        if (!sws)
        {
            return;
        }

        sws.showColors       = showColors;
        sws.showSurface      = showSurface;
        sws.showIntersection = showIntersection;
        sws.showHighlights   = showHighlights;
        sws.showDepth        = showDepth;
        sws.showWaves        = showWaves;

        sws.substance          = substance;
        sws.hasSubstanceParams = hasSubstanceParams; //If Substance changed, is set to false
    }
    //Get shader and Substance values
    void getProperties()
    {
        stylizedWater = selected.GetComponent <StylizedWater>();

        //Get shader and substance properties

        stylizedWater.getProperties();

        material  = stylizedWater.material;
        substance = stylizedWater.substance;

        //Meta
        showColors       = stylizedWater.showColors;
        showSurface      = stylizedWater.showSurface;
        showIntersection = stylizedWater.showIntersection;
        showHighlights   = stylizedWater.showHighlights;
        showDepth        = stylizedWater.showDepth;
        showWaves        = stylizedWater.showWaves;

        isMobileAdvanced = stylizedWater.isMobileAdvanced;
        isMobileBasic    = stylizedWater.isMobileBasic;


        shaderName = stylizedWater.shaderName;

        #region Shader parameters
        waterColor   = stylizedWater.waterColor;
        fresnelColor = stylizedWater.fresnelColor;
        rimColor     = stylizedWater.rimColor;

        transparency      = stylizedWater.transparency;
        glossiness        = stylizedWater.glossiness;
        reflectionCubemap = stylizedWater.reflectionCubemap;
        fresnel           = stylizedWater.fresnel;

        surfaceHighlight       = stylizedWater.surfaceHighlight;
        surfaceHighlightSize   = stylizedWater.surfaceHighlightSize;
        surfaceHighlightTiling = stylizedWater.surfaceHighlightTiling;

        depth         = stylizedWater.depth;
        depthDarkness = stylizedWater.depthDarkness;

        rimSize    = stylizedWater.rimSize;
        rimFalloff = stylizedWater.rimFalloff;

        worldSpaceTiling = stylizedWater.worldSpaceTiling;
        tiling           = stylizedWater.tiling;
        rimTiling        = stylizedWater.rimTiling;

        refractionAmount = stylizedWater.refractionAmount;

        waveSpeed    = stylizedWater.waveSpeed;
        waveStrength = stylizedWater.waveStrength;

        tesselation = stylizedWater.tesselation;
        #endregion

        #region Substance parameters
        seed                  = stylizedWater.seed;
        normalStrength        = stylizedWater.normalStrength;
        intersectionStyleList = stylizedWater.intersectionStyleList;
        intersectionStyle     = stylizedWater.intersectionStyle;
        waveStyle             = stylizedWater.waveStyle;
        waveStyleList         = stylizedWater.waveStyleList;

        useCustomNormals      = stylizedWater.useCustomNormals;
        useCustomIntersection = stylizedWater.useCustomIntersection;

        customIntersection = stylizedWater.customIntersection;
        customNormal       = stylizedWater.customNormal;

        normals   = stylizedWater.normals;
        shadermap = stylizedWater.shadermap;

        //Substance values are not null, safe to apply
        hasSubstanceParams = stylizedWater.hasSubstanceParams; //true if has Substance
        #endregion

        setSubstanceParameters(); //Go back and re-run this function now that hasSubstanceParams is True
    }