public static hwmEditorCoroutine Start(IEnumerator routine)
    {
        hwmEditorCoroutine coroutine = new hwmEditorCoroutine(routine);

        coroutine.Start();
        return(coroutine);
    }
Exemplo n.º 2
0
    protected void OnGUI()
    {
        switch (m_EditorState)
        {
        case EditorState.ChooseSnake:
            EditorGUILayout.HelpBox("Drap snake editor prefab to this", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            m_SnakeEditorPrefab = EditorGUILayout.ObjectField("Snake Editor Prefab", m_SnakeEditorPrefab, typeof(GameObject), false) as GameObject;
            if (m_SnakeEditorPrefab != null && GUILayout.Button("Editor"))
            {
                m_SnakeEditor = (PrefabUtility.InstantiatePrefab(m_SnakeEditorPrefab) as GameObject).GetComponent <slSnakeEditor>();
                if (m_SnakeEditor != null)
                {
                    m_EditorState = EditorState.EditorSnake;
                    m_SnakeEditorUpdateCoroutine = hwmEditorCoroutine.Start(UpdateSnakeEditor());
                }
                else
                {
                    DestroyImmediate(m_SnakeEditor.gameObject);
                    m_SnakeEditor = null;
                    EditorUtility.DisplayDialog("Editor snake failed", "Invalid snake editor prefab", "OK");
                }
            }
            EditorGUILayout.EndHorizontal();
            break;

        case EditorState.EditorSnake:
            OnGUI_EditorSnake();
            break;
        }
    }
Exemplo n.º 3
0
    private void DisposeEditorSnake()
    {
        if (m_SnakeEditorUpdateCoroutine != null)
        {
            m_SnakeEditorUpdateCoroutine.Stop();
            m_SnakeEditorUpdateCoroutine = null;
        }

        m_SnakeEditorPrefab = null;
        if (m_SnakeEditor != null)
        {
            DestroyImmediate(m_SnakeEditor.gameObject);
            m_SnakeEditor = null;
        }
    }
Exemplo n.º 4
0
    protected void OnGUI()
    {
        if (!hwmRenderDocUtility.IsInstalled())
        {
            EditorGUILayout.HelpBox("Not installed RenderDoc", MessageType.Error);
            return;
        }
        else if (!hwmRenderDocUtility.IsSupported())
        {
            EditorGUILayout.HelpBox("Not supported RenderDoc", MessageType.Error);
            return;
        }
        else if (!hwmRenderDocUtility.IsLoaded())
        {
            EditorGUILayout.HelpBox("Not loaded RenderDoc", MessageType.Error);
            hwmRenderDocUtility.Load();
            return;
        }

        #region Scene
        EditorGUILayout.BeginHorizontal();
        SceneAsset sceneAsset = EditorGUILayout.ObjectField("Analyze Scene", m_SceneAsset, typeof(SceneAsset), true) as SceneAsset;
        if (sceneAsset != m_SceneAsset)
        {
            m_SceneAsset = sceneAsset;
            m_Setting.AnalyzeScenePath.SetValue(AssetDatabase.GetAssetPath(m_SceneAsset));
        }
        EditorGUILayout.EndHorizontal();

        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().path != m_Setting.AnalyzeScenePath.GetValue())
        {
            if (GUILayout.Button("Open Analyze Scene"))
            {
                EditorSceneManager.OpenScene(m_Setting.AnalyzeScenePath.GetValue(), OpenSceneMode.Single);
            }
            return;
        }
        #endregion

        m_Camera = EditorGUILayout.ObjectField("Camera", m_Camera, typeof(Camera), false) as Camera;
        if (m_Camera == null)
        {
            m_Camera = FindObjectOfType <Camera>();
        }
        if (m_Camera == null)
        {
            EditorGUILayout.HelpBox("Must have a camera", MessageType.Error);
            return;
        }

        EditorGUILayout.Space();
        m_Setting.ParticleSimulateTime.SetValue(EditorGUILayout.FloatField("Particle Simulate Time", m_Setting.ParticleSimulateTime.GetValue()));
        m_Setting.RelativeSize.SetValue(EditorGUILayout.Slider("Relative Size", m_Setting.RelativeSize.GetValue(), 0.0f, 5.0f));
        m_Setting.DestroyAfterAnalyze.SetValue(EditorGUILayout.Toggle("Destroy After Analyze", m_Setting.DestroyAfterAnalyze.GetValue()));

        if (m_AnalyzeCoroutine != null &&
            m_AnalyzeCoroutine.IsRuning())
        {
            EditorGUILayout.HelpBox("Analyzing", MessageType.Info);
            return;
        }

        GameObject gameObject = Selection.activeObject as GameObject;
        if (!gameObject)
        {
            EditorGUILayout.HelpBox("Must section a Prefab or GameObject", MessageType.Error);
            return;
        }

        if (GUILayout.Button("Analyze"))
        {
            bool isPrefab = !string.IsNullOrEmpty(AssetDatabase.GetAssetPath(gameObject));
            m_AnalyzeCoroutine = hwmEditorCoroutine.Start(Analyze(gameObject, isPrefab));
        }
    }