protected virtual void AwakeOverride() { if (gameObject.GetComponent <Dispatcher>() == null) { gameObject.AddComponent <Dispatcher>(); } m_assetBundleLoader = AssetBundleLoader; m_assetDB = AssetDB; m_materialUtil = MaterialUtil; m_shaderUtil = ShaderUtil; m_typeMap = TypeMap; m_objectFactory = ObjectFactory; m_serializer = Serializer; m_storage = Storage; m_project = Project; m_playerPrefs = PlayerPrefs; }
private void OnDestroy() { if (m_instance == this) { m_instance = null; } OnDestroyOverride(); m_assetBundleLoader = null; m_materialUtil = null; m_shaderUtil = null; m_assetDB = null; m_typeMap = null; m_objectFactory = null; m_serializer = null; m_storage = null; m_project = null; m_playerPrefs = null; }
public override object WriteTo(object obj) { obj = base.WriteTo(obj); if (obj == null) { return(null); } Material o = (Material)obj; if (m_assetDB.IsMapped(shader)) { o.shader = FromID <Shader>(shader); } else { o.shader = Shader.Find(m_shaderName); } if (m_keywords != null) { foreach (string keyword in m_keywords) { o.EnableKeyword(keyword); } } if (m_propertyNames != null) { int textureIndex = 0; for (int i = 0; i < m_propertyNames.Length; ++i) { string name = m_propertyNames[i]; RTShaderPropertyType type = m_propertyTypes[i]; switch (type) { case RTShaderPropertyType.Color: if (m_propertyValues[i].ValueBase is PersistentColor <TID> ) { o.SetColor(name, (PersistentColor <TID>)m_propertyValues[i].ValueBase); } break; case RTShaderPropertyType.Float: if (m_propertyValues[i].ValueBase is float) { o.SetFloat(name, (float)m_propertyValues[i].ValueBase); } break; case RTShaderPropertyType.Range: if (m_propertyValues[i].ValueBase is float) { o.SetFloat(name, (float)m_propertyValues[i].ValueBase); } break; case RTShaderPropertyType.TexEnv: if (m_propertyValues[i].ValueBase is TID) { o.SetTexture(name, FromID <Texture>((TID)m_propertyValues[i].ValueBase)); if (m_textureOffset != null) { o.SetTextureOffset(name, m_textureOffset[textureIndex]); } if (m_textureScale != null) { o.SetTextureScale(name, m_textureScale[textureIndex]); } textureIndex++; } break; case RTShaderPropertyType.Vector: if (m_propertyValues[i].ValueBase is PersistentVector4 <TID> ) { o.SetVector(name, (PersistentVector4 <TID>)m_propertyValues[i].ValueBase); } break; case RTShaderPropertyType.Unknown: break; } } } IMaterialUtil util = IOC.Resolve <IMaterialUtil>(); util.SetMaterialKeywords(o); o.renderQueue = m_renderQueue; return(obj); }
private void Awake() { m_materialUtils = new URPLitMaterialUtils(); IOC.Register(m_materialUtils); }