private void GenerateTriggerMaterial() { if (this.triggerMaterial == null) { string shaderName = "Scroll_XY_Alpha"; Shader shader = Service.AssetManager.Shaders.GetShader(shaderName); if (shader == null) { return; } this.triggerMaterial = UnityUtils.CreateMaterial(shader); this.triggerRadius.GetComponent <Renderer>().sharedMaterial = this.triggerMaterial; this.triggerMaterial.color = this.TRIGGER_COLOR; this.triggerMaterial.SetFloat("_tint", 1f); this.triggerMaterial.SetFloat("_SpeedX", 0f); if (this.triggerTexture != null) { this.AssignTriggerMaterial(); } else if (this.triggerHandle == AssetHandle.Invalid) { this.triggerRadius.SetActive(false); TextureVO textureVO = Service.StaticDataController.Get <TextureVO>("trigger_radius"); Service.AssetManager.Load(ref this.triggerHandle, textureVO.AssetName, new AssetSuccessDelegate(this.OnTextureLoaded), null, this.triggerMaterial); } } }
private void GenerateEffectMaterial() { if (this.effectMaterial == null) { string shaderName = "Scroll_XY_Alpha"; Shader shader = Service.Get <AssetManager>().Shaders.GetShader(shaderName); if (shader == null) { return; } this.effectMaterial = UnityUtils.CreateMaterial(shader); this.effectRadius.GetComponent <Renderer>().sharedMaterial = this.effectMaterial; this.effectMaterial.color = this.EFFECT_COLOR; this.effectMaterial.SetFloat("_tint", 0.9f); this.effectMaterial.SetFloat("_SpeedY", 0f); if (this.effectTexture != null) { this.AssignEffectMaterial(); return; } if (this.effectHandle == AssetHandle.Invalid) { this.effectRadius.SetActive(false); TextureVO textureVO = Service.Get <IDataController>().Get <TextureVO>("effect_radius"); Service.Get <AssetManager>().Load(ref this.effectHandle, textureVO.AssetName, new AssetSuccessDelegate(this.OnTextureLoaded), null, this.effectMaterial); } } }
private void CreateSpawnGameObject() { MeshRenderer meshRenderer; MeshFilter meshFilter; if (this.gameObject == null) { this.gameObject = new GameObject("SpawnProtectionView"); meshRenderer = this.gameObject.AddComponent <MeshRenderer>(); meshFilter = this.gameObject.AddComponent <MeshFilter>(); } else { meshRenderer = this.gameObject.GetComponent <MeshRenderer>(); meshFilter = this.gameObject.GetComponent <MeshFilter>(); } this.gameObject.SetActive(false); this.gameObject.transform.position = new Vector3(0f, 0.045f, 0f); this.gameObjectExists = true; this.gameObjectVisible = false; meshFilter.sharedMesh = this.mesh; if (this.material == null) { string shaderName = "Grid_Protection_PL"; Shader shader = Service.Get <AssetManager>().Shaders.GetShader(shaderName); if (shader == null) { return; } this.material = UnityUtils.CreateMaterial(shader); meshRenderer.GetComponent <Renderer>().sharedMaterial = this.material; if (this.texture != null) { this.material.mainTexture = this.texture; } else if (this.textureHandle == AssetHandle.Invalid) { TextureVO textureVO = Service.Get <IDataController>().Get <TextureVO>("textureSpawnProtection1"); Service.Get <AssetManager>().Load(ref this.textureHandle, textureVO.AssetName, new AssetSuccessDelegate(this.OnTextureLoaded), null, null); } } this.material.SetFloat("_Speed", 0.4f); this.material.color = Color.black; this.animAlphaIn = new AnimColor(this.material, 1f, Color.black, Color.white); this.animAlphaIn.EaseFunction = new Easing.EasingDelegate(Easing.QuintEaseOut); this.animAlphaOut = new AnimColor(this.material, 1f, Color.white, Color.black); this.animAlphaOut.Delay = 3f; this.animAlphaOut.EaseFunction = new Easing.EasingDelegate(Easing.QuintEaseIn); this.animAlphaOut.OnCompleteCallback = new Action <Anim>(this.OnAlphaOutComplete); }
private void CreateNonSharedMaterials(GameObject assetGameObject) { MeshRenderer[] componentsInChildren = assetGameObject.GetComponentsInChildren <MeshRenderer>(true); SkinnedMeshRenderer[] componentsInChildren2 = assetGameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true); Dictionary <Material, Material> dictionary = new Dictionary <Material, Material>(); int i = 0; int num = componentsInChildren.Length; while (i < num) { if (dictionary.ContainsKey(componentsInChildren[i].sharedMaterial)) { componentsInChildren[i].sharedMaterial = dictionary[componentsInChildren[i].sharedMaterial]; } else { Material sharedMaterial = componentsInChildren[i].sharedMaterial; Material material = UnityUtils.CreateMaterial(sharedMaterial.shader); material.mainTexture = sharedMaterial.mainTexture; material.mainTextureOffset = sharedMaterial.mainTextureOffset; material.mainTextureScale = sharedMaterial.mainTextureScale; dictionary.Add(componentsInChildren[i].sharedMaterial, material); componentsInChildren[i].material = material; this.unsharedMaterials.Add(material); } i++; } int j = 0; int num2 = componentsInChildren2.Length; while (j < num2) { if (dictionary.ContainsKey(componentsInChildren2[j].sharedMaterial)) { componentsInChildren2[j].sharedMaterial = dictionary[componentsInChildren2[j].sharedMaterial]; } else { Material material2 = UnityUtils.CreateMaterial(componentsInChildren2[j].sharedMaterial.shader); material2.CopyPropertiesFromMaterial(componentsInChildren2[j].sharedMaterial); dictionary.Add(componentsInChildren2[j].sharedMaterial, material2); componentsInChildren2[j].material = material2; this.unsharedMaterials.Add(material2); } j++; } dictionary.Clear(); }
protected void CreateMaterial(string shaderName) { Shader shader = Service.Get <AssetManager>().Shaders.GetShader(shaderName); this.quadMaterial = UnityUtils.CreateMaterial(shader); }
private void CreateNonSharedMaterials(GameObject assetGameObject) { MeshRenderer[] componentsInChildren = assetGameObject.GetComponentsInChildren <MeshRenderer>(true); SkinnedMeshRenderer[] componentsInChildren2 = assetGameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true); Dictionary <Material, Material> dictionary = new Dictionary <Material, Material>(); int i = 0; int num = componentsInChildren.Length; while (i < num) { if (componentsInChildren[i].sharedMaterial == null) { Service.Get <StaRTSLogger>().ErrorFormat("sharedMaterial missing on {0}", new object[] { assetGameObject.name }); } else if (dictionary.ContainsKey(componentsInChildren[i].sharedMaterial)) { componentsInChildren[i].sharedMaterial = dictionary[componentsInChildren[i].sharedMaterial]; } else { Material material = UnityUtils.CreateMaterial(componentsInChildren[i].sharedMaterial.shader); material.CopyPropertiesFromMaterial(componentsInChildren[i].sharedMaterial); dictionary.Add(componentsInChildren[i].sharedMaterial, material); componentsInChildren[i].material = material; this.unsharedMaterials.Add(material); this.AttemptShaderSwapIfNeeded(material); } i++; } int j = 0; int num2 = componentsInChildren2.Length; while (j < num2) { if (componentsInChildren2[j].sharedMaterial == null) { Service.Get <StaRTSLogger>().ErrorFormat("skinnedMeshRenderer missing on {0}", new object[] { assetGameObject.name }); } else if (dictionary.ContainsKey(componentsInChildren2[j].sharedMaterial)) { componentsInChildren2[j].sharedMaterial = dictionary[componentsInChildren2[j].sharedMaterial]; } else { Material material2 = UnityUtils.CreateMaterial(componentsInChildren2[j].sharedMaterial.shader); material2.CopyPropertiesFromMaterial(componentsInChildren2[j].sharedMaterial); dictionary.Add(componentsInChildren2[j].sharedMaterial, material2); componentsInChildren2[j].material = material2; this.unsharedMaterials.Add(material2); this.AttemptShaderSwapIfNeeded(material2); } j++; } dictionary.Clear(); }