Subversion Repository Public Repository

Nextrek

Diff Revisions 167 vs 168 for /3DSpace/Assets/SpaceUnity/Editor/SU_SpaceSceneConstructionKitEditor.cs

Diff revisions: vs.
  @@ -834,11 +834,11 @@
834 834 // --- HANDLE STARS ---
835 835 if (_starsEnabled) {
836 836 string _starName = _starsMatch[UnityEngine.Random.Range(0, _starsMatch.Count)].ToString();
837 - Camera _spaceCamera = _sInstantiated.transform.Find("SpaceCamera").camera;
837 + Camera _spaceCamera = _sInstantiated.transform.Find("SpaceCamera").GetComponent<Camera>();
838 838 if (_spaceCamera != null) {
839 839 // This is a workaround because Unity seems to not keep material material changes to previously instantiated cameras
840 840 Editor.DestroyImmediate(_spaceCamera.gameObject);
841 - _spaceCamera = ((GameObject)PrefabUtility.InstantiatePrefab((GameObject) (GameObject)AssetDatabase.LoadAssetAtPath(_basePath + _prefabSpaceCamera, typeof (GameObject)))).camera;
841 + _spaceCamera = ((GameObject)PrefabUtility.InstantiatePrefab((GameObject) (GameObject)AssetDatabase.LoadAssetAtPath(_basePath + _prefabSpaceCamera, typeof (GameObject)))).GetComponent<Camera>();
842 842 _spaceCamera.transform.parent = _sInstantiated.transform;
843 843 }
844 844 _spaceCamera.GetComponent<Skybox>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathStars + _starName + ".mat", typeof (Material));
  @@ -861,7 +861,7 @@
861 861 GameObject _nebulaInstantiated = (GameObject)PrefabUtility.InstantiatePrefab((GameObject) _nebulaPrefab);
862 862 _nebulaInstantiated.transform.parent = _sInstantiated.transform;
863 863 string _nebulaName = _nebulasMatch[UnityEngine.Random.Range(0, _nebulasMatch.Count)].ToString();
864 - _nebulaInstantiated.renderer.material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathNebulas + _nebulaName + ".mat", typeof (Material));
864 + _nebulaInstantiated.GetComponent<Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathNebulas + _nebulaName + ".mat", typeof (Material));
865 865 _nebulaInstantiated.transform.eulerAngles = new Vector3(UnityEngine.Random.Range(0,360), UnityEngine.Random.Range(0,360), UnityEngine.Random.Range(0,360));
866 866 }
867 867 }
  @@ -884,13 +884,13 @@
884 884 _galaxyName = _galaxiesMatch[UnityEngine.Random.Range(0, _galaxiesMatch.Count)].ToString();
885 885 _galaxyInstantiated.transform.eulerAngles = new Vector3(UnityEngine.Random.Range(0,360), UnityEngine.Random.Range(0,360), UnityEngine.Random.Range(0,360));
886 886 float _newGalaxyScale = UnityEngine.Random.Range(-0.1f, 0.1f) + _galaxyDistanceScales[UnityEngine.Random.Range(0, _galaxyDistanceScales.Count)];
887 - _galaxyTextureTransform.renderer.material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathGalaxies+_galaxyName+".mat", typeof (Material));
887 + _galaxyTextureTransform.GetComponent<Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathGalaxies+_galaxyName+".mat", typeof (Material));
888 888 _galaxyInstantiated.transform.localScale = new Vector3(_newGalaxyScale, _newGalaxyScale, _newGalaxyScale);
889 889 _galaxyTextureTransform.Translate(new Vector3(0,0,(1.0f - _newGalaxyScale) * 1000),Space.Self);
890 - _galaxyTextureTransform.Find("Point light").light.intensity = _galaxyTextureTransform.Find("Point light").light.intensity * _newGalaxyScale;
890 + _galaxyTextureTransform.Find("Point light").GetComponent<Light>().intensity = _galaxyTextureTransform.Find("Point light").GetComponent<Light>().intensity * _newGalaxyScale;
891 891 if (!_galaxyLightHasFlare) {
892 892 // Disable light flare if not enabled
893 - _galaxyTextureTransform.Find("Point light").light.flare = null;
893 + _galaxyTextureTransform.Find("Point light").GetComponent<Light>().flare = null;
894 894 }
895 895 if (!_galaxyIsLightsource) {
896 896 // Destroy light source if not enabled
  @@ -946,12 +946,12 @@
946 946 _planetObject.transform.eulerAngles = new Vector3(UnityEngine.Random.Range(0,360), UnityEngine.Random.Range(0,360), UnityEngine.Random.Range(0,360));
947 947 _planetObject.GetComponent<SU_Planet>().planetRotation = new Vector3(0,0,_planetRotationScales[UnityEngine.Random.Range(0, _planetRotationScales.Count)]);
948 948 UnityEngine.Object _planetMaterial = AssetDatabase.LoadAssetAtPath(_basePath + _pathPlanets+_planetName+".mat", typeof (UnityEngine.Object));
949 - _planetObject.renderer.material = (Material) _planetMaterial;
949 + _planetObject.GetComponent<Renderer>().material = (Material) _planetMaterial;
950 950
951 951 // Atmosphere
952 952 if (_planetAtmosphere) {
953 953 // Change the material of the atmosphere according to label on planet material
954 - _planetInstantiated.transform.Find("Atmosphere").renderer.material = (Material) _hPlanetAtmospheres[GetPlanetAtmosphere(_planetMaterial)];
954 + _planetInstantiated.transform.Find("Atmosphere").GetComponent<Renderer>().material = (Material) _hPlanetAtmospheres[GetPlanetAtmosphere(_planetMaterial)];
955 955 } else {
956 956 // Atmosphere not enabled, remove the atmosphere transform from the instantiated prefab
957 957 UnityEngine.Object.DestroyImmediate(_planetInstantiated.transform.Find("Atmosphere").gameObject);
  @@ -988,7 +988,7 @@
988 988 _planetMoonMesh.transform.localPosition = new Vector3(_planetMoonMesh.transform.position.x * _moonDistance,0,0);
989 989 // Select and apply a random moon surface material
990 990 string _moonMaterial = _lPlanetMoons[UnityEngine.Random.Range(0, _lPlanetMoons.Count)];
991 - _planetMoonMesh.gameObject.renderer.material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathMoons + _moonMaterial + ".mat", typeof (Material));
991 + _planetMoonMesh.gameObject.GetComponent<Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathMoons + _moonMaterial + ".mat", typeof (Material));
992 992 }
993 993 }
994 994
  @@ -1016,7 +1016,7 @@
1016 1016 float _planetRingsScale = UnityEngine.Random.Range(0.8f, 1.2f);
1017 1017 _planetRingsInstantiated.transform.localScale = new Vector3(_planetRingsScale, _planetRingsScale, _planetRingsScale);
1018 1018 string _ringMaterial = _lPlanetRings[UnityEngine.Random.Range(0, _lPlanetRings.Count)];
1019 - _planetRingsInstantiated.renderer.material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathRings + _ringMaterial + ".mat", typeof (Material));
1019 + _planetRingsInstantiated.GetComponent<Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathRings + _ringMaterial + ".mat", typeof (Material));
1020 1020 }
1021 1021 }
1022 1022
  @@ -1056,8 +1056,8 @@
1056 1056
1057 1057 Transform _localStarChildTransform = _localStarInstantiated.transform.Find("LocalStarChild");
1058 1058
1059 - _localStarChildTransform.Find("ParticleSystem-Body").GetComponent<ParticleSystem>().renderer.material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathLocalStarsBody + _localStarBodyMatch[UnityEngine.Random.Range(0, _localStarBodyMatch.Count)] + ".mat", typeof (Material));
1060 - _localStarChildTransform.Find("ParticleSystem-Prominence").GetComponent<ParticleSystem>().renderer.material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathLocalStarsProminence + _localStarProminenceMatch[UnityEngine.Random.Range(0, _localStarProminenceMatch.Count)] + ".mat", typeof (Material));
1059 + _localStarChildTransform.Find("ParticleSystem-Body").GetComponent<ParticleSystem>().GetComponent<Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathLocalStarsBody + _localStarBodyMatch[UnityEngine.Random.Range(0, _localStarBodyMatch.Count)] + ".mat", typeof (Material));
1060 + _localStarChildTransform.Find("ParticleSystem-Prominence").GetComponent<ParticleSystem>().GetComponent<Renderer>().material = (Material)AssetDatabase.LoadAssetAtPath(_basePath + _pathLocalStarsProminence + _localStarProminenceMatch[UnityEngine.Random.Range(0, _localStarProminenceMatch.Count)] + ".mat", typeof (Material));
1061 1061 if (!_localStarIsLightsource) {
1062 1062 // Destroy light source if not enabled
1063 1063 UnityEngine.Object.DestroyImmediate(_localStarChildTransform.Find("Point light").gameObject);
  @@ -1067,20 +1067,20 @@
1067 1067 if (_localStarLightColor != LocalStarLightColor.WHITE) {
1068 1068 switch (_localStarColorUsed) {
1069 1069 case LocalStarColor.BLUE:
1070 - _localStarChildTransform.Find("Directional light").light.color = _colorLocalStarBlue;
1071 - _localStarChildTransform.Find("Point light").light.color = _colorLocalStarBlue;
1070 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().color = _colorLocalStarBlue;
1071 + _localStarChildTransform.Find("Point light").GetComponent<Light>().color = _colorLocalStarBlue;
1072 1072 break;
1073 1073 case LocalStarColor.YELLOW:
1074 - _localStarChildTransform.Find("Directional light").light.color = _colorLocalStarYellow;
1075 - _localStarChildTransform.Find("Point light").light.color = _colorLocalStarYellow;
1074 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().color = _colorLocalStarYellow;
1075 + _localStarChildTransform.Find("Point light").GetComponent<Light>().color = _colorLocalStarYellow;
1076 1076 break;
1077 1077 case LocalStarColor.ORANGE:
1078 - _localStarChildTransform.Find("Directional light").light.color = _colorLocalStarOrange;
1079 - _localStarChildTransform.Find("Point light").light.color = _colorLocalStarOrange;
1078 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().color = _colorLocalStarOrange;
1079 + _localStarChildTransform.Find("Point light").GetComponent<Light>().color = _colorLocalStarOrange;
1080 1080 break;
1081 1081 case LocalStarColor.RED:
1082 - _localStarChildTransform.Find("Directional light").light.color = _colorLocalStarRed;
1083 - _localStarChildTransform.Find("Point light").light.color = _colorLocalStarRed;
1082 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().color = _colorLocalStarRed;
1083 + _localStarChildTransform.Find("Point light").GetComponent<Light>().color = _colorLocalStarRed;
1084 1084 break;
1085 1085 }
1086 1086 }
  @@ -1088,35 +1088,35 @@
1088 1088 // Light Intensity
1089 1089 switch (_localStarLightIntensityUsed) {
1090 1090 case LocalStarLightIntensity.VERY_LOW:
1091 - _localStarChildTransform.Find("Directional light").light.intensity = _intensityLocalStarVeryLow;
1092 - _localStarChildTransform.Find("Point light").light.intensity = _intensityLocalStarVeryLow;
1091 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().intensity = _intensityLocalStarVeryLow;
1092 + _localStarChildTransform.Find("Point light").GetComponent<Light>().intensity = _intensityLocalStarVeryLow;
1093 1093 break;
1094 1094 case LocalStarLightIntensity.LOW:
1095 - _localStarChildTransform.Find("Directional light").light.intensity = _intensityLocalStarLow;
1096 - _localStarChildTransform.Find("Point light").light.intensity = _intensityLocalStarLow;
1095 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().intensity = _intensityLocalStarLow;
1096 + _localStarChildTransform.Find("Point light").GetComponent<Light>().intensity = _intensityLocalStarLow;
1097 1097 break;
1098 1098 case LocalStarLightIntensity.MEDIUM:
1099 - _localStarChildTransform.Find("Directional light").light.intensity = _intensityLocalStarMedium;
1100 - _localStarChildTransform.Find("Point light").light.intensity = _intensityLocalStarMedium;
1099 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().intensity = _intensityLocalStarMedium;
1100 + _localStarChildTransform.Find("Point light").GetComponent<Light>().intensity = _intensityLocalStarMedium;
1101 1101 break;
1102 1102 case LocalStarLightIntensity.HIGH:
1103 - _localStarChildTransform.Find("Directional light").light.intensity = _intensityLocalStarHigh;
1104 - _localStarChildTransform.Find("Point light").light.intensity = _intensityLocalStarHigh;
1103 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().intensity = _intensityLocalStarHigh;
1104 + _localStarChildTransform.Find("Point light").GetComponent<Light>().intensity = _intensityLocalStarHigh;
1105 1105 break;
1106 1106 case LocalStarLightIntensity.VERY_HIGH:
1107 - _localStarChildTransform.Find("Directional light").light.intensity = _intensityLocalStarVeryHigh;
1108 - _localStarChildTransform.Find("Point light").light.intensity = _intensityLocalStarVeryHigh;
1107 + _localStarChildTransform.Find("Directional light").GetComponent<Light>().intensity = _intensityLocalStarVeryHigh;
1108 + _localStarChildTransform.Find("Point light").GetComponent<Light>().intensity = _intensityLocalStarVeryHigh;
1109 1109 break;
1110 1110 }
1111 1111
1112 1112 // Light Flare
1113 1113 if (!_localStarLightHasFlare) {
1114 1114 // Disable light flare if not enabled
1115 - _localStarChildTransform.Find("Point light").light.flare = null;
1115 + _localStarChildTransform.Find("Point light").GetComponent<Light>().flare = null;
1116 1116 } else {
1117 1117 // Select the correct flare color & size
1118 1118 string _localStarFlareName = _localStarFlareMatch[UnityEngine.Random.Range(0, _localStarFlareMatch.Count)];
1119 - _localStarChildTransform.Find("Point light").light.flare = (Flare)AssetDatabase.LoadAssetAtPath(_basePath + _pathLocalStarsFlare + _localStarFlareName + ".flare", typeof(Flare));
1119 + _localStarChildTransform.Find("Point light").GetComponent<Light>().flare = (Flare)AssetDatabase.LoadAssetAtPath(_basePath + _pathLocalStarsFlare + _localStarFlareName + ".flare", typeof(Flare));
1120 1120 }
1121 1121 }
1122 1122 }