Esempio n. 1
0
    /// <summary>
    ///  -1 -> not in build   0 -> disabled in build   2 -> enabled in build
    /// </summary>
    private int GetBuildState(out string assetPath, out int indexInBuild)
    {
        SceneAsset sceneAsset = _target.Editor_GetScene();

        assetPath = AssetDatabase.GetAssetOrScenePath(sceneAsset);
        EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
        for (int i = 0; i < scenes.Length; i++)
        {
            if (scenes[i].path == assetPath)
            {
                indexInBuild = i;
                if (scenes[i].enabled)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }

        indexInBuild = -1;
        return(-1);
    }
    public static bool OnOpenAsset(int instanceID, int line)
    {
        UnityEngine.Object obj       = EditorUtility.InstanceIDToObject(instanceID);
        SceneInfo          sceneInfo = obj as SceneInfo;

        if (sceneInfo != null)
        {
            if (sceneInfo.Editor_GetScene() != null)
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetOrScenePath(sceneInfo.Editor_GetScene()));
                return(true);
            }
        }

        return(false); // we did not handle the open
    }
Esempio n. 3
0
    public static bool OnOpenAsset(int instanceID, int line)
    {
        UnityEngine.Object obj       = EditorUtility.InstanceIDToObject(instanceID);
        SceneInfo          sceneInfo = obj as SceneInfo;

        if (sceneInfo != null)
        {
            if (sceneInfo.Editor_GetScene() != null)
            {
                if (!Application.isPlaying)
                {
                    EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
                }
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetOrScenePath(sceneInfo.Editor_GetScene()));
                return(true);
            }
        }

        return(false); // we did not handle the open
    }
    public static bool OnOpenAsset(int instanceID, int line)
    {
        SceneInfo sceneInfo = EditorUtility.InstanceIDToObject(instanceID) as SceneInfo;

        if (sceneInfo != null)
        {
            if (sceneInfo.Editor_GetScene() != null)
            {
                Scene[] allScenes = new Scene[SceneManager.sceneCount];
                for (int i = 0; i < SceneManager.sceneCount; i++)
                {
                    allScenes[i] = SceneManager.GetSceneAt(i);
                }
                if (EditorSceneManager.SaveModifiedScenesIfUserWantsTo(allScenes))
                {
                    EditorSceneManager.OpenScene(AssetDatabase.GetAssetOrScenePath(sceneInfo.Editor_GetScene()));
                }
                return(true);
            }
        }

        return(false); // we did not handle the open
    }