public static void SetSceneAsset(this AddressableSceneAsset addressableSceneAsset, SceneAsset sceneAsset) { var path = AssetDatabase.GetAssetPath(sceneAsset); if (string.IsNullOrEmpty(path) == false) { var guid = AssetDatabase.AssetPathToGUID(path); addressableSceneAsset.Guid = guid; } }
public static SceneAsset GetSceneAsset(this AddressableSceneAsset sceneAsset) { if (string.IsNullOrEmpty(sceneAsset.Guid)) { return(null); } var path = AssetDatabase.GUIDToAssetPath(sceneAsset.Guid); var scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(path); return(scene); }
AddressableSceneAsset ContentTypeListItem(Rect pos, AddressableSceneAsset itemValue) { if (itemValue == null) { itemValue = new AddressableSceneAsset(); } int indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; EditorGUI.BeginChangeCheck(); var sceneAsset = itemValue.GetSceneAsset(); var newSceneAsset = EditorGUI.ObjectField(new Rect(pos.x, pos.y, pos.width - 20f, pos.height), sceneAsset, typeof(SceneAsset), false) as SceneAsset; if (EditorGUI.EndChangeCheck()) { itemValue.SetSceneAsset(newSceneAsset); } itemValue.Addressable = GUI.Toggle(new Rect(pos.x + pos.width - 20f, pos.y, 20f, pos.height), itemValue.Addressable, AddressableGuiContent); EditorGUI.indentLevel = indentLevel; return(itemValue); }