Exemplo n.º 1
0
    /// <summary>
    /// ステージの読み込み
    /// </summary>
    /// <param name="stageEditor">ベースクラス</param>
    private void LoadStage(StageEditor stageEditor)
    {
        stageEditor.loadStage = true;
        stageEditor.Data      = Instantiate(pre);
        stageEditor.stageName = stageEditor.Data.stageName;
        GameObject o = Instantiate(pre.stage);

        stageEditor.cells         = pre.gridCells;
        stageEditor.gridPos       = new GameObject[pre.gridCells.x, pre.gridCells.y, pre.gridCells.z];
        stageEditor._StageObjects = new GameObject[pre.gridCells.x, pre.gridCells.y, pre.gridCells.z];
        stageEditor.EditStageInit();

ReStart:
        foreach (Transform child in o.transform)
        {
            child.gameObject.transform.parent = stageEditor.stageRoot.transform;
            Vector3Int v = Vector3Int.zero;
            if (child.GetComponent <MyCellIndex>())
            {
                v = child.GetComponent <MyCellIndex>().cellIndex;
            }
            stageEditor.gridPos[v.x, v.y, v.z].GetComponent <HighlightObject>().IsAlreadyInstalled = true;
            stageEditor._StageObjects[v.x, v.y, v.z] = child.gameObject;
        }

        if (o.transform.childCount != 0)
        {
            goto ReStart;
        }
        Destroy(o);
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        StageEditor stageEditor = target as StageEditor;

        base.OnInspectorGUI();
        GUILayout.Label("-以下変更可-");
        pre = (PrefabStageData)EditorGUILayout.ObjectField("読み込むステージ", pre, typeof(ScriptableObject), false);
        if (GUILayout.Button("NewStage"))
        {
            if (!EditorApplication.isPlaying)
            {
                return;
            }
            stageEditor.EditStageInit();
            stageEditor.isCreateStage = true;
        }

        if (GUILayout.Button("LoadStage"))
        {
            if (!EditorApplication.isPlaying)
            {
                return;
            }
            LoadStage(stageEditor);
            stageEditor.isCreateStage = true;
        }
    }