//----------------------------------------------------- void Start() { guiMenuConfiguration = GameObject.Find("MainScene").GetComponent<GUIMenuConfiguration>(); guiMenuInteraction = GameObject.Find("MainScene").GetComponent<GUIMenuInteraction>(); if(skin == null) skin = (GUISkin)Resources.Load("skins/mode2D"); // -- Initialisation variables membres -- mLoopLightMode = false; mLightMode = LightMode.off; mCurColorH = 0f; mCurLightCol = new Color(); mLightSystemRoot = null; mWaterSpec = null; mLEDmat = null; mMainSpotlight = null; mOldSpaScale = new Vector3(); // -- Variables transitions animées -- mAnimOnOff = false; mAnimOnOffProg = 0f; mSpotlightsStartI = 0f; mSpotlightsEndI = 0f; mGlowColorStart = Color.black; mGlowColorEnd = Color.black; mMatLEDcolStart = Color.black; mMatLEDcolEnd = Color.black; mWaterSelfiColStart = Color.black; mWaterSelfiColEnd = Color.black; mAnimMainSpotOnOff = false; mAnimMainSpotOnOffProg = 0f; mMainSpotIstart = 0f; mMainSpotIend = 0f; // -- Récupérations des objets de la scène dont on a besoin -- mSpa = transform; Transform child, child2; for(int i=0; i<mSpa.GetChildCount(); i++) { child = mSpa.GetChild(i); if(child.name == sLightSystemRootName) mLightSystemRoot = child; // Nœud parent du système de lumières else if(child.name == sWaterParentName) { for(int j=0; j<child.GetChildCount(); j++) { child2 = child.GetChild(j); if(child2.name.Equals(sWaterSpecName)) mWaterSpec = child2.gameObject; // Eau (celle avec le shader DispNormRimSpec-like) } } else if(child.name == sLEDmeshName) { for(int j=0; j<child.GetComponent<Renderer>().materials.Length; j++) { if(child.GetComponent<Renderer>().materials[j].name.Contains(sLEDmaterialName)) mLEDmat = child.GetComponent<Renderer>().materials[j]; // Matériau du mesh du verre des LEDs } } } // -- Si un objet est absent, afficher une erreur et désactiver le script -- if(mLightSystemRoot == null) { DeactivateWithLogError(sLightSystemRootName); return; } if(mWaterSpec == null) { DeactivateWithLogError(sWaterSpecName); return; } if(mLEDmat == null) { DeactivateWithLogError(sLEDmaterialName); return; } // -- Récupération des spotlights et des matériaux des glows des LEDs -- mLEDglows = new List<GameObject>(); mLEDspots = new List<Light>(); for(int i=0; i<mLightSystemRoot.GetChildCount(); i++) { child = mLightSystemRoot.GetChild(i); if(child.name == sMainSpotlightName) mMainSpotlight = child.GetComponent<Light>(); else { for(int j=0; j<child.GetChildCount(); j++) { child2 = child.GetChild(j); if(child2.name == sLEDglowObjectName) mLEDglows.Add(child2.gameObject); else if(child2.name == sLEDspotObjectName) mLEDspots.Add(child2.GetComponent<Light>()); } // foreach child of child } // if not main spotlight } // For each child if(mMainSpotlight == null) { DeactivateWithLogError(sMainSpotlightName); return; } // -- Couleur moyenne de la coque (correspond normalement à "lumières éteintes") -- if (mWaterSpec.GetComponent<Renderer>().material.HasProperty("_MainColor")) mLinerColor = mWaterSpec.GetComponent<Renderer>().material.GetColor("_MainColor"); // -- Couleur du matériau du verre des LED (correspond normalement à "lumières éteintes") -- mLEDmatColor = mLEDmat.GetColor("_Color"); // -- Echelle du spa (et range des spotlights) -- mOldSpaScale = Vector3.one; // Note : Pas mOldSpaScale = mSpa.LocalScale sinon la range des proj n'est pas mise à jour au swap. mMainSpotlightBaseRange = mMainSpotlight.range; mLEDSpotBaseRanges = new float[mLEDspots.Count]; for(int i=0; i<mLEDspots.Count; i++) mLEDSpotBaseRanges[i] = mLEDspots[i].range; // Note : mSpotsLitI est MÀJ par spaConfigWater, qui appelle updateSpotsIntensity à son 1er Update() }
// Use this for initialization void Start() { if(_uiSkin == null) _uiSkin = (GUISkin)Resources.Load("skins/DynShelterSkin"); UI = new DynShelterUI(this); menuConf = GameObject.Find("MainScene").GetComponent<GUIMenuConfiguration>(); menuInteract = GameObject.Find("MainScene").GetComponent<GUIMenuInteraction>(); interact = Camera.main.GetComponent<ObjInteraction>(); _dsMdl = new DynShelterModel(this); _nextInsertion = true; StartCoroutine(LoadConf()); _upperArea = new Rect(Screen.width/2 - 300,225,600,120); _leftArea = new Rect(0.0f, 0.0f, Screen.width * 2.0f, Screen.height); InstantiateRessources(); UsefullEvents.mode2DStateUpdated += QuitOverride; UsefullEvents.OnResizeWindowEnd += UIRelocate; CenterDeployAndFeetLimit(); }