void RefreshShaderGraphObject() { if (shaderGraph == null && !object.ReferenceEquals(shaderGraph, null)) { string assetPath = AssetDatabase.GetAssetPath(shaderGraph.GetInstanceID()); var newShaderGraph = AssetDatabase.LoadAssetAtPath <ShaderGraphVfxAsset>(assetPath); if (newShaderGraph != null) { shaderGraph = newShaderGraph; } } }
public ShaderGraphVfxAsset GetOrRefreshShaderGraphObject() { //This is the only place where shaderGraph property is updated or read if (shaderGraph == null && !object.ReferenceEquals(shaderGraph, null)) { string assetPath = AssetDatabase.GetAssetPath(shaderGraph.GetInstanceID()); var newShaderGraph = AssetDatabase.LoadAssetAtPath <ShaderGraphVfxAsset>(assetPath); if (newShaderGraph != null) { shaderGraph = newShaderGraph; } } return(shaderGraph); }
public ShaderGraphVfxAsset GetOrRefreshShaderGraphObject() { //This is the only place where shaderGraph property is updated or read if (shaderGraph == null) { if (!object.ReferenceEquals(shaderGraph, null)) //Invalid reference object, force reimport. { string assetPath = AssetDatabase.GetAssetPath(shaderGraph.GetInstanceID()); var newShaderGraph = AssetDatabase.LoadAssetAtPath <ShaderGraphVfxAsset>(assetPath); if (newShaderGraph != null) { shaderGraph = newShaderGraph; } } else if (!string.IsNullOrEmpty(shadergraphGUID)) //shaderGraph really null, load from save guid. { shaderGraph = AssetDatabase.LoadAssetAtPath <ShaderGraphVfxAsset>(AssetDatabase.GUIDToAssetPath(shadergraphGUID)); } } return(shaderGraph); }