void OnEnable() { if (Resources.FindObjectsOfTypeAll <VFXResources>().Length > 1) { Debug.LogError("Having more than one VFXResources in you project is unsupported"); } s_Instance = this; }
void OnEnable() { if (AssetDatabase.FindAssets("t:VFXResources").Length > 1) { Debug.LogError("Having more than one VFXResources in your project is unsupported"); } s_Instance = this; m_Searched = false; }
private static void Initialize() { string[] guids = AssetDatabase.FindAssets("t:VFXResources"); VFXResources asset = null; if (guids.Length > 0) { asset = AssetDatabase.LoadAssetAtPath <VFXResources>(AssetDatabase.GUIDToAssetPath(guids[0])); } if (asset == null) { Debug.LogWarning("Could not find " + defaultFileName + ", creating..."); VFXResources newAsset = CreateInstance <VFXResources>(); newAsset.particleTexture = SafeLoadAssetAtPath <Texture2D>(defaultPath + "Textures/DefaultParticle.tga"); newAsset.noiseTexture = SafeLoadAssetAtPath <Texture2D>(defaultPath + "Textures/Noise.tga"); newAsset.vectorField = SafeLoadAssetAtPath <Texture3D>(defaultPath + "Textures/vectorfield.asset"); newAsset.signedDistanceField = SafeLoadAssetAtPath <Texture3D>(defaultPath + "Textures/SignedDistanceField.asset"); newAsset.mesh = Resources.GetBuiltinResource <Mesh>("New-Capsule.fbx"); newAsset.shader = Shader.Find("Hidden/Default StaticMeshOutput"); newAsset.animationCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0.0f, 0.0f, 0.0f, 0.0f), new Keyframe(0.25f, 0.25f, 0.0f, 0.0f), new Keyframe(1.0f, 0.0f, 0.0f, 0.0f), }); newAsset.gradient = new Gradient(); newAsset.gradient.colorKeys = new GradientColorKey[] { new GradientColorKey(Color.white, 0.0f), new GradientColorKey(Color.gray, 1.0f), }; newAsset.gradient.alphaKeys = new GradientAlphaKey[] { new GradientAlphaKey(0.0f, 0.0f), new GradientAlphaKey(1.0f, 0.1f), new GradientAlphaKey(0.8f, 0.8f), new GradientAlphaKey(0.0f, 1.0f), }; AssetDatabase.CreateAsset(newAsset, "Assets/" + defaultFileName); asset = SafeLoadAssetAtPath <VFXResources>("Assets/" + defaultFileName); } s_Instance = asset; }
static void LoadUserResourcesIfNeeded() { if (s_Instance == null && (!m_Searched || !object.ReferenceEquals(s_Instance, null))) // if instance is null and either it has never been searched or it was found but it has been destroyed since last time { foreach (var guid in AssetDatabase.FindAssets("t:VFXResources")) { s_Instance = AssetDatabase.LoadAssetAtPath <VFXResources>(AssetDatabase.GUIDToAssetPath(guid)); if (s_Instance != null) { return; } } s_Instance = null; m_Searched = true; } }