public void Init(SerialConnect_Sponge _s, int i) { _serial = _s; id = i; float ofs_y = 0.7f - 0.7f * id; Transform t = GetComponent <Transform>(); t.localPosition = new Vector3(t.localPosition.x, t.localPosition.y + ofs_y); }
/// <summary> /// プロット用のオブジェクトを追加する関数 /// ※UGUI上ではなく、オブジェクトのシェーダー /// </summary> /// <param name="_serial"></param> /// <param name="id"></param> void CreatePlotMeshOb(SerialConnect_Sponge _serial, int id) { GameObject _ob = null; Material _mat = null; //アセットバンドル関係を削除したのでここで何かしなければならない。(覚えていない・・・) // _ob = AssetBundleManager.Instance.GetGameObjectFromAssetBundle(MeshName, SceneManager.GetActiveScene().name); // _mat = AssetBundleManager.Instance.GetMaterialFromAssetBundle(MeshShaderName, SceneManager.GetActiveScene().name); GameObject _tmp_ob; _tmp_ob = Instantiate(_ob, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); _tmp_ob.name = MeshName + "_" + id.ToString("00"); _tmp_ob.GetComponent <Renderer>().material = _mat; _tmp_ob.GetComponent <Renderer>().material.shader = Shader.Find("Unlit/VertexColor"); _tmp_ob.GetComponent <Sponge_PlotMeshUnit>().Init(_serial, id); //プロット用オブジェクトに入っているスクリプトに値を渡す _tmp_ob.transform.parent = MeshPlotSpace.transform; }
int[] TrianglesTable; //三角形 //こんなイメージ // 6 7 8 // // [1,0] [1,1] // // 3 4 5 // // [0,0] [1,0] // // 0 1 2 //TrianglesTable[0] = 0 //TrianglesTable[1] = 4 //TrianglesTable[2] = 1 //TrianglesTable[3] = 0 //TrianglesTable[4] = 3 //TrianglesTable[5] = 4 //TrianglesTable[6] = 1 //TrianglesTable[7] = 5 //TrianglesTable[8] = 2 //・・・ /// <summary> /// 変換したデータ分のprefabを生成する /// </summary> public void SetDefine(SerialConnect_Sponge _serial, int id) { //解析用テーブル分オブジェクトを生成する int cnt_x = Sponge_Manage.Matrix_x; int cnt_y = Sponge_Manage.Matrix_y; float pitch = Sponge_Manage.pitch / 20.0f; float ofs_x = (-1) * cnt_x * pitch / 2.0f; //Unity上の原点に中央が来るようにオフセットを加算する float ofs_y = (-1) * cnt_y * pitch / 2.0f; //メッシュ用のテーブルを設定 // Init((-1.0f * pitch * 0.5f) + ofs_x, (-1.0f * pitch * 0.5f) + ofs_y, pitch, cnt_x + 1, cnt_y + 1); //左下の頂点とピッチ、頂点数を渡している Init((-1.0f * pitch * 0.5f) + ofs_x, (-1.0f * pitch * 0.5f) + ofs_y, pitch, cnt_x, cnt_y); //左下の頂点とピッチ、頂点数を渡している //メッシュをオブジェクトに表示するか、UGUI上に表示するか if (isMeshObject) { CreatePlotMeshOb(_serial, id); } else { //UGUI上に表示する場合は、初期化タイミングがMesh出来た後なので何もしない。 } }