Esempio n. 1
0
 public MaterialChangeDeltas(roomMaterialConfiguration newConfig)
 {
     this.newConfig = newConfig;
     deltaEmR       = Mathf.Abs(newConfig.emissMatColor.r - newConfig.mat.GetColor("_EmissionColor").r);
     deltaEmG       = Mathf.Abs(newConfig.emissMatColor.g - newConfig.mat.GetColor("_EmissionColor").g);
     deltaEmB       = Mathf.Abs(newConfig.emissMatColor.b - newConfig.mat.GetColor("_EmissionColor").b);
 }
Esempio 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;
    }