Ejemplo n.º 1
0
 public LightChangeDeltas(roomLightConfiguration newConfig, Light sampleLight)
 {
     this.newConfig      = newConfig;
     lightClassification = newConfig.targetClassification;
     deltaIntensity      = Mathf.Abs(newConfig.intensity - sampleLight.intensity);
     deltaRange          = Mathf.Abs(newConfig.range - sampleLight.range);
     deltaR = Mathf.Abs(newConfig.realTimeLightColor.r - sampleLight.color.r);
     deltaG = Mathf.Abs(newConfig.realTimeLightColor.g - sampleLight.color.g);
     deltaB = Mathf.Abs(newConfig.realTimeLightColor.b - sampleLight.color.b);
 }
Ejemplo n.º 2
0
    void saveVisuals()
    {
        if (!EditorUtility.DisplayDialog("Saving New Room Visual",
                                         "Go through all your changers. Only the ones that are expanded will be saved as configurations in this saved holder",
                                         "Go Ahead",
                                         "Cancel")
            )
        {
            return;
        }

        //Credit to http://wiki.unity3d.com/index.php/CreateScriptableObjectAsset for the below code
        roomVisualsHolder newHolder = ScriptableObject.CreateInstance <roomVisualsHolder>();

        foreach (roomVisualsLightsChanger lightChanger in helper.changers.Where((lightChanger) => lightChanger.isExpanded))
        {
            roomLightConfiguration lightConfig = new roomLightConfiguration();
            lightConfig.targetClassification = lightChanger.targetClassification;
            lightConfig.realTimeLightColor   = lightChanger.testRealTimeLightColor;
            lightConfig.range     = lightChanger.testRange;
            lightConfig.intensity = lightChanger.testIntensity;
            newHolder.lightConfigurations.Add(lightConfig);
        }


        foreach (roomVisualsMaterialChanger matChanger in helper.materialChangers.Where((mChanger) => mChanger.isExpanded))
        {
            if (matChanger.mat == null)
            {
                continue;
            }
            roomMaterialConfiguration matConfig = new roomMaterialConfiguration();
            matConfig.mat           = matChanger.mat;
            matConfig.emissMatColor = matChanger.testMainEmissMatColor;
            newHolder.materialConfigurations.Add(matConfig);
        }


        string path             = "Assets";
        string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New " + typeof(roomVisualsHolder).ToString() + ".asset");

        AssetDatabase.CreateAsset(newHolder, assetPathAndName);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        EditorUtility.FocusProjectWindow();
        Selection.activeObject = newHolder;
    }