LoginSignup
1
1

More than 5 years have passed since last update.

Inventory / unity > code v0.1 > Row:Prev/Next, Column:Prev/Nextボタン実装

Last updated at Posted at 2016-08-21
動作確認
Unity 5.3.5-f1 on MacOS X El Capitan

関連 http://qiita.com/7of9/items/523a9ec838eaae05bcc1

v0.1 機能

qiita.png

Row, ColumnのPrev/Nextボタンの実装。
今のところダミーデータを使用。

code v0.1

v0.1 @ github

SampleData.cs

ダミーデータ読込み用。

SampleData.cs
using UnityEngine;
using System.Collections;

namespace NS_SampleData
{
    public static class SampleData
    {
        // 1: caseNo
        // 2: row
        // 3: column
        // 4: name (key)
        // 5: about
        // 6: datasheet URL (TODO)

        public static string GetDataOfRow(int row) {
            switch (row) {
            case 0:
                return "1,1,1,MAX232,The MAX220-MAX249 family of line drivers/receivers is ...";
            case 1:
                return "1,1,2,MAX44242,The MAX44242 provides a combination of high voltage, low noise, low input ...";
            }
            return "";
        }

        public static string GetDataOfColumn(int clm) {
            switch (clm) {
            case 0:
                return "1,2,1,HC-SR04,Power supply: 5V DC. Ultrasonic Frequency: 40k Hz\n• Resolution: 1 cm ...";
            case 1:
                return "1,2,2,MPL115A2,an absolute pressure sensor with a digital I2C output targeting low cost applications...";
            }
            return "";
        }

    }
}

InventoryCS.cs

メインの処理。

InventoryCS.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using NS_SampleData;

/*
 * v0.1 2016 Aug. 21
 *   - add MoveColumn()
 *   - add MoveRow()
 *   - add SampleData.cs
 *   - add UI components (unique ID, Case No, Row, Column, About, DataSheet)
 */

public class InventoryCS : MonoBehaviour {

    public InputField ID_uniqueID;
    public Text T_caseNo;
    public Text T_row;
    public Text T_column;
    public InputField IF_name;
    public Text T_about;
    string datasheetURL;

    void Start () {
        T_about.text = NS_SampleData.SampleData.GetDataOfRow (0);   
    }

    void Update () {

    }

    public void MoveRow(bool next) {
        if (next == false) { // previous
            T_about.text = NS_SampleData.SampleData.GetDataOfRow (0);   
        } else {
            T_about.text = NS_SampleData.SampleData.GetDataOfRow (1);
        }
    }

    public void MoveColumn(bool next) {
        if (next == false) { // previous
            T_about.text = NS_SampleData.SampleData.GetDataOfColumn(0);
        } else {
            T_about.text = NS_SampleData.SampleData.GetDataOfColumn (1);
        }
    }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1