//--------------------------------------------------------------------------- INIT public void Initialize(IHotSpotMgr iHotSpotMgr, Transform oParentT, string sNameHotspot, bool bEnableEditing, Vector3 vecPosLocalOffset, float nScale, int nLayer) { _iHotSpotMgr = iHotSpotMgr; _oParentT = oParentT; _sNameHotspot = sNameHotspot; transform.name = "Hotspot-" + sNameHotspot; transform.parent = _oParentT; transform.localPosition = vecPosLocalOffset; transform.localRotation = Quaternion.identity; _bEnableEditing = bEnableEditing; _vecPosAtStartup = transform.position; _nScaleAtStartup = nScale; transform.localScale = new Vector3(_nScaleAtStartup, _nScaleAtStartup, _nScaleAtStartup); gameObject.layer = nLayer; // All hotspots have to exist in the hotspot layer in order for CCursor to detect them. GetComponent<Collider>().isTrigger = true; GetComponent<Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Diffuse")); _oColorUnselected = new Color(UnityEngine.Random.Range(0.1f,0.6f), UnityEngine.Random.Range(0.1f,0.6f), UnityEngine.Random.Range(0.1f,0.6f), C_TransparencyLevel); _oColorSelected = new Color(_oColorUnselected.r*C_RatioColor_Highlight, _oColorUnselected.g*C_RatioColor_Highlight, _oColorUnselected.b*C_RatioColor_Highlight, _oColorUnselected.a*C_RatioColor_Highlight); _oColorActivated = new Color(_oColorUnselected.r*C_RatioColor_Activated, _oColorUnselected.g*C_RatioColor_Activated, _oColorUnselected.b*C_RatioColor_Activated, _oColorUnselected.a*C_RatioColor_Activated); GetComponent<Renderer>().sharedMaterial.color = _oColorUnselected; }
const float C_TransparencyLevel = 0.4f; // How transparent to make hotspots #endregion Fields #region Methods //--------------------------------------------------------------------------- STATIC CREATION public static CHotSpot CreateHotspot(IHotSpotMgr iHotSpotMgr, Transform oParentT, string sNameHotspot, bool bEnableEditing, Vector3 vecPosLocalOffset = new Vector3(), float nScaleMult = 1.0f, int nLayer = CCursor.C_Layer_HotSpot) { float nScale = CCursor.C_HotSpot_DefaultSize * nScaleMult; Transform oHotSpotT = (Transform)GameObject.Instantiate(CGame.INSTANCE._oCursor._Prefab_HotSpot); // This plane will convert the rays from the camera to the mouse into a 3D position on the cutting plane. CHotSpot oHotSpot = oHotSpotT.GetComponent<CHotSpot>(); //###WEAK: Scale constants everwhere as absolute values? Make relative to some well known size? oHotSpot.Initialize(iHotSpotMgr, oParentT, sNameHotspot, bEnableEditing, vecPosLocalOffset, nScale, nLayer); return oHotSpot; }