public override void OnStart(StartState state) { base.OnStart(state); screenView = new PlasmaScreenView(); screenView.part = this.part; screenView.showImageDelegate = ShowImage; if (string.IsNullOrEmpty(imagePath) == false) { Texture2D image = new Texture2D(1, 1); WWW www = new WWW("file://" + imagePath); www.LoadImageIntoTexture(image); ShowImage(image, imagePath); } }
public void Start() { if (HighLogic.LoadedSceneIsFlight == false) { return; } screenView = new PlasmaScreenView(); getDefaultTexture(); //Get the screen's render material Transform target = internalProp.FindModelTransform(screenTransform); if (target == null) { return; } rendererMaterial = target.GetComponent <Renderer>(); if (showAlphaControl) { SetScreenVisible(screenIsVisible); } //Get the prop state helper. propStateHelper = this.part.FindModuleImplementing <WBIPropStateHelper>(); if (propStateHelper != null) { imagePath = propStateHelper.LoadProperty(internalProp.propID, "imagePath"); if (string.IsNullOrEmpty(imagePath) == false && System.IO.File.Exists(imagePath)) { Texture2D image = new Texture2D(1, 1); WWW www = new WWW("file://" + imagePath); www.LoadImageIntoTexture(image); ShowImage(image, imagePath); } string value = propStateHelper.LoadProperty(internalProp.propID, "enableRandomScreens"); if (string.IsNullOrEmpty(value) == false) { enableRandomImages = bool.Parse(value); } if (enableRandomImages) { cycleStartTime = Planetarium.GetUniversalTime(); } value = propStateHelper.LoadProperty(internalProp.propID, "screenSwitchTime"); if (string.IsNullOrEmpty(value) == false) { screenSwitchTime = float.Parse(value); } value = propStateHelper.LoadProperty(internalProp.propID, "screenIsVisible"); if (string.IsNullOrEmpty(value) == false) { screenIsVisible = bool.Parse(value); } } Transform trans = internalProp.FindModelTransform("ScreenTrigger"); if (trans != null) { GameObject goButton = trans.gameObject; if (goButton != null) { ButtonClickWatcher clickWatcher = goButton.GetComponent <ButtonClickWatcher>(); if (clickWatcher == null) { clickWatcher = goButton.AddComponent <ButtonClickWatcher>(); } clickWatcher.clickDelegate = OnScreenClick; } } //Setup screen view screenView.showImageDelegate = ShowImage; screenView.toggleScreenDelegate = SetScreenVisible; screenView.showAlphaControl = this.showAlphaControl; }