public override void OnInspectorGUI()
    {
        StageEditor_uchimura stageEditor = target as StageEditor_uchimura;

        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;
        }
    }
示例#2
0
    /// <summary>
    /// 既存ステージの読み込み
    /// </summary>
    public void LoadStage()
    {
        if (stageSelect_d.captionText.text == "None")
        {
            Debug.Log("⚠ステージが選択されていません!"); return;
        }
        loadStage                  = true;
        isCreateStage              = true;
        biomeSelect.interactable   = false;
        stageSelect_d.interactable = false;
        nStageB.interactable       = false;
        lStageB.interactable       = false;

        PrefabStageData data = Resources.Load <PrefabStageData>("EditData/" + biomeSelect.captionText.text + "/" + stageNameInputField.text);

        Data = Instantiate(data);

        stageNameInputField.text = Data.editName;
        enemyEditCanvas.GetComponent <EnemyDataSet>().sName = Data.editName;
        GameObject o = Instantiate(Data.stage);

        stageSizeInputField[0].text = Data.gridCells.x.ToString();
        stageSizeInputField[1].text = Data.gridCells.y.ToString();
        stageSizeInputField[2].text = Data.gridCells.z.ToString();
        cells         = new Vector3Int(Data.gridCells.x, Data.gridCells.y, Data.gridCells.z);
        grid          = new GameObject[Data.gridCells.x, Data.gridCells.y + 1, Data.gridCells.z];
        _StageObjects = new GameObject[Data.gridCells.x, Data.gridCells.y + 1, Data.gridCells.z];
        EditStageInit();
        isCreateStage = true;

ReStart:
        foreach (Transform child in o.transform)
        {
            child.gameObject.transform.SetParent(stageRoot.transform);
            Vector3Int v = Vector3Int.zero;
            if (child.GetComponent <MyCellIndex>())
            {
                v = child.GetComponent <MyCellIndex>().cellIndex;
                if (v.y != cells.y && isGenerateFloor.isOn)
                {
                    v = new Vector3Int(v.x, v.y + 1, v.z);
                }
                child.GetComponent <MyCellIndex>().cellIndex = v;

                grid[v.x, v.y, v.z].GetComponent <HighlightObject>().IsAlreadyInstalled = true;
                _StageObjects[v.x, v.y, v.z] = child.gameObject;
            }
            else if (child.gameObject.name == "EnemyMaster")
            {
                enemyEditCanvas.GetComponent <EnemyDataSet>().createEnemy = true;
                enemyEditCanvas.GetComponent <EnemyDataSet>().LoadEnemyData(child.gameObject);
            }
        }
        if (o.transform.childCount != 0)
        {
            goto ReStart;
        }
        Destroy(o);
    }
示例#3
0
    /// <summary>
    /// ステージがプレビューで一定の大きさになるようにサイズ調整する
    /// </summary>
    /// <param name="data">ステージデータアセット</param>
    /// <param name="i">列インデックス</param>
    /// <param name="j">行インデックス</param>
    private void StageReSize(PrefabStageData data, int i, int j)
    {
        if (scaleAdjust.x <= 0 || scaleAdjust.y < 0)
        {
            return;
        }
        Vector2 scale = new Vector2(data.gridCells.x, data.gridCells.z);

        if (scale.x > scaleAdjust.x || scale.y > scaleAdjust.y)
        {
            int a, b, r;
            if (scale.x > scale.y)
            {
                a = (int)scale.x;
                b = (int)scale.y;
            }
            else
            {
                a = (int)scale.y;
                b = (int)scale.x;
            }

            r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }

            float x = scale.x / b;
            float z = scale.y / b;
            float magni;

            if (x > z)
            {
                magni = scaleAdjust.x / x;
            }
            else
            {
                magni = scaleAdjust.y / z;
            }

            Vector2 reSize = new Vector2((x * magni) / scale.x, (z * magni) / scale.y);
            viewStage[i, j].defScale = new Vector3(reSize.x, 1, reSize.y);
        }
        else
        {
            viewStage[i, j].defScale = Vector3.one;
        }
    }