//Should be called in update for timing to be correct void transitionTo(roomVisualsHolder newHolder) { if (themeChanged != null) { themeChanged(newHolder); } lightDeltas.Clear(); matDeltas.Clear(); foreach (roomLightConfiguration lightConfig in newHolder.lightConfigurations) { LightClass sampleLightClass = FindObjectsOfType <LightClass>().Where(light => light.classification == lightConfig.targetClassification).FirstOrDefault(); if (sampleLightClass != null) { lightDeltas.Add(new LightChangeDeltas(lightConfig, sampleLightClass.light)); } } foreach (roomMaterialConfiguration matConfig in newHolder.materialConfigurations) { matDeltas.Add(new MaterialChangeDeltas(matConfig)); } //Changing will start on next update() stopTime = Time.time + completionTime; }
void loadVisuals() { string path = EditorUtility.OpenFilePanel("Select a theme", "Assets", "asset"); //Making path relative to Assets folder if (path.StartsWith(Application.dataPath)) { path = "Assets" + path.Substring(Application.dataPath.Length); } roomVisualsHolder loadedHolder = AssetDatabase.LoadAssetAtPath <roomVisualsHolder>(path); if (loadedHolder == null) { return; } foreach (roomLightConfiguration lightConfig in loadedHolder.lightConfigurations) { roomVisualsLightsChanger lightChanger = helper.changers .Where(changer => changer.targetClassification == lightConfig.targetClassification) .FirstOrDefault(); if (lightChanger == null) { continue; } lightChanger.testIntensity = lightConfig.intensity; lightChanger.testRealTimeLightColor = lightConfig.realTimeLightColor; lightChanger.testRange = lightConfig.range; helper.testRealtimeLights(lightChanger); } foreach (roomMaterialConfiguration matConfig in loadedHolder.materialConfigurations) { roomVisualsMaterialChanger matChanger = helper.materialChangers .Where(changer => changer.mat == matConfig.mat) .FirstOrDefault(); if (matChanger == null) { continue; } matChanger.testMainEmissMatColor = matConfig.emissMatColor; helper.testMaterialEmission(matChanger); } }
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; }
public void determineIfShouldBeAttracted(roomVisualsHolder holder) { if (holder.targetType == type) { attractingAbsorber = gameManager.Instance.absorbers.OrderBy(absorber => Vector3.SqrMagnitude(transform.position - absorber.transform.position)).First(); rb.velocity = Vector3.zero; isBeingAttracted = true; } else if (isBeingAttracted) //Cube was being attracted before but not anymore... { isBeingAttracted = false; if (isFrozen) { prefreezeLinearVelocity = Random.onUnitSphere * instanciationVeclocityMagnitude; } else { rb.velocity = Random.onUnitSphere * instanciationVeclocityMagnitude; } } }
public void updateTargetType(roomVisualsHolder holder) { currentTargetType = holder.targetType; }