// private System.Runtime.InteropServices.GCHandle gc_handle_; void Start() { UnityPluginIF.Load("UnityPlugin"); // list_ = new List<Vector3>(); // list_.Capacity = 100; // list_.Add(new Vector3(111f, 222f, 333f)); // gc_handle_ = System.Runtime.InteropServices.GCHandle.Alloc(list_, // System.Runtime.InteropServices.GCHandleType.Pinned); }
void Start() { #if UNITY_EDITOR UnityPluginIF.Load("UnityPlugin"); #endif BoxingPool.init(); WaterSplash.Instance.init(material_, null /* reflection texture */); var col = new Color(1f, 1f, 1f); WaterSplash.Instance.SetBaseColor(ref col); WaterSplash.Instance.SetGravity(0f); var pos = new Vector3(0f, 0f, 0f); var vel = new Vector3(0f, 0f, 0f); spawn(ref pos, ref vel); // StartCoroutine(loop()); }
void OnApplicationQuit() { #if UNITY_EDITOR UnityPluginIF.Unload(); #endif }
void OnDestroy() { UnityPluginIF.Unload(); }
private IEnumerator initialize() { camera_final_ = camera_final_holder_.GetComponent <Camera>(); camera_final_.enabled = false; UnityPluginIF.Load("UnityPlugin"); Application.targetFrameRate = (int)RENDER_FPS; DontDestroyOnLoad(gameObject); stopwatch_ = new System.Diagnostics.Stopwatch(); stopwatch_.Start(); rendering_front_ = 0; #if UTJ_MULTI_THREADED manual_reset_event_ = new System.Threading.ManualResetEvent(false); update_sync_frame_ = 0; #endif setFPS(DefaultFps); update_frame_ = 0; update_time_ = 0f; render_frame_ = 0; render_sync_frame_ = 0; pause_ = false; spectator_mode_ = auto_; canvas_.SetActive(false); camera_ = camera_holder_.GetComponent <Camera>(); ProjectionMatrix = camera_.projectionMatrix; BoxingPool.init(); InputManager.Instance.init(); Controller.Instance.init(auto_); TaskManager.Instance.init(); MyCollider.createPool(); Bullet.createPool(); EnemyBullet.createPool(); EnemyLaser.createPool(); Enemy.createPool(); WaterSurface.Instance.init(water_surface_input_material_, water_surface_distortion_, water_surface_line_render_); WaterSurfaceRenderer.Instance.init(camera_.transform); Spark.Instance.init(spark_material_); Beam.Instance.init(beam_material_); BeamRenderer.Instance.init(Beam.Instance); Beam2.Instance.init(beam2_material_); Beam2Renderer.Instance.init(Beam2.Instance); WaterSplash.Instance.init(water_splash_material_, WaterSurfaceRenderer.Instance.getReflectionTexture()); WaterSplashRenderer.Instance.init(WaterSplash.Instance); AuraEffect.Instance.init(); Explosion.Instance.init(explosion_material_); ExplosionRenderer.Instance.init(Explosion.Instance); Hahen.Instance.init(hahen_material_); HahenRenderer.Instance.init(Hahen.Instance); Shield.Instance.init(shield_material_); ShieldRenderer.Instance.init(Shield.Instance); Debris.Instance.init(debris_material_); Dust.Instance.init(dust_material_); LightEnvironmentController.Instance.init(); Sight.Instance.init(sight_material_); SightRenderer.Instance.init(Sight.Instance); MySprite.Instance.init(sprites_, sprite_material_); MySpriteRenderer.Instance.init(camera_); MyFont.Instance.init(font_, font_material_); MyFontRenderer.Instance.init(); GaugeJump.Create(); PerformanceMeter.Instance.init(); draw_buffer_ = new DrawBuffer[2]; for (int i = 0; i < 2; ++i) { draw_buffer_[i].init(); } yield return(Player.Instance.initialize()); my_camera_ = MyCamera.create(); spectator_camera_ = SpectatorCamera.create(); set_camera(spectator_mode_); if (player_prefab_ != null) { GameObject go = Instantiate(player_prefab_); // player_renderer_ = go.GetComponent<PlayerRenderer>(); muscle_motion_renderer_player_ = go.GetComponent <MuscleMotionRenderer>(); muscle_motion_renderer_player_.init(); } if (enemy_zako_prefab_ != null) { enemy_zako_pool_ = new GameObject[ENEMY_ZAKO_MAX]; for (var i = 0; i < ENEMY_ZAKO_MAX; ++i) { enemy_zako_pool_[i] = Instantiate(enemy_zako_prefab_) as GameObject; enemy_zako_pool_[i].SetActive(false); } } if (dragon_head_prefab_ != null) { dragon_head_pool_ = new GameObject[DRAGON_HEAD_MAX]; for (var i = 0; i < DRAGON_HEAD_MAX; ++i) { dragon_head_pool_[i] = Instantiate(dragon_head_prefab_) as GameObject; dragon_head_pool_[i].SetActive(false); } } if (dragon_body_prefab_ != null) { dragon_body_pool_ = new GameObject[DRAGON_BODY_MAX]; for (var i = 0; i < DRAGON_BODY_MAX; ++i) { dragon_body_pool_[i] = Instantiate(dragon_body_prefab_) as GameObject; dragon_body_pool_[i].SetActive(false); } } if (dragon_tail_prefab_ != null) { dragon_tail_pool_ = new GameObject[DRAGON_TAIL_MAX]; for (var i = 0; i < DRAGON_TAIL_MAX; ++i) { dragon_tail_pool_[i] = Instantiate(dragon_tail_prefab_) as GameObject; dragon_tail_pool_[i].SetActive(false); } } // audio audio_sources_bullet_ = new AudioSource[AUDIOSOURCE_BULLET_MAX]; for (var i = 0; i < AUDIOSOURCE_BULLET_MAX; ++i) { audio_sources_bullet_[i] = gameObject.AddComponent <AudioSource>(); audio_sources_bullet_[i].clip = se_bullet_; audio_sources_bullet_[i].volume = 0.04f; } audio_source_bullet_index_ = 0; audio_sources_explosion_ = new AudioSource[AUDIOSOURCE_EXPLOSION_MAX]; for (var i = 0; i < AUDIOSOURCE_EXPLOSION_MAX; ++i) { audio_sources_explosion_[i] = gameObject.AddComponent <AudioSource>(); audio_sources_explosion_[i].clip = se_explosion_; audio_sources_explosion_[i].volume = 0.025f; } audio_source_explosion_index_ = 0; audio_sources_laser_ = new AudioSource[AUDIOSOURCE_LASER_MAX]; for (var i = 0; i < AUDIOSOURCE_LASER_MAX; ++i) { audio_sources_laser_[i] = gameObject.AddComponent <AudioSource>(); audio_sources_laser_[i].clip = se_laser_; audio_sources_laser_[i].volume = 0.025f; } audio_source_laser_index_ = 0; audio_sources_shield_ = new AudioSource[AUDIOSOURCE_SHIELD_MAX]; for (var i = 0; i < AUDIOSOURCE_SHIELD_MAX; ++i) { audio_sources_shield_[i] = gameObject.AddComponent <AudioSource>(); audio_sources_shield_[i].clip = se_shield_; audio_sources_shield_[i].volume = 0.020f; } audio_source_shield_index_ = 0; audio_sources_shield_ = new AudioSource[AUDIOSOURCE_SHIELD_MAX]; for (var i = 0; i < AUDIOSOURCE_SHIELD_MAX; ++i) { audio_sources_shield_[i] = gameObject.AddComponent <AudioSource>(); audio_sources_shield_[i].clip = se_shield_; audio_sources_shield_[i].volume = 0.025f; } audio_source_shield_index_ = 0; audio_sources_bgm_ = gameObject.AddComponent <AudioSource>(); audio_sources_bgm_.clip = bgm01_; audio_sources_bgm_.volume = 0.05f; audio_sources_bgm_.loop = true; is_bgm_playing_ = false; GameManager.Instance.init(); #if UTJ_MULTI_THREADED update_thread_ = new Thread(thread_entry); update_thread_.Priority = System.Threading.ThreadPriority.Highest; update_thread_.Start(); #endif #if UNITY_PS4 || UNITY_EDITOR int rw = 1920; int rh = 1080; #elif UNITY_PSP2 int rw = 480; int rh = 272; #else int rw = 568; int rh = 320; #endif render_texture_ = new RenderTexture(rw, rh, 24 /* depth */, RenderTextureFormat.ARGB32); render_texture_.Create(); camera_.targetTexture = render_texture_; final_material_.mainTexture = render_texture_; initialized_ = true; camera_final_.enabled = true; }
void OnApplicationQuit() { UnityPluginIF.Unload(); }
public void renderUpdate(int front) { #if NOT_RECOMENDED_OPTIMIZATION // var sw = new System.Diagnostics.Stopwatch(); // sw.Start(); int num = UnityPluginIF.ConvertArrayFromList(WATERSPLASH_MAX, gc_handle_alive_table_items_.AddrOfPinnedObject(), gc_handle_positions_items_.AddrOfPinnedObject(), gc_handle_velocities_items_.AddrOfPinnedObject(), gc_handle_uv2_list_items_.AddrOfPinnedObject(), gc_handle_vertices_items_[front].AddrOfPinnedObject(), gc_handle_normals_items_[front].AddrOfPinnedObject(), gc_handle_uv2s_items_[front].AddrOfPinnedObject()); object boxed_num8 = BoxingPool.IntList[num * 8]; object boxed_num18 = BoxingPool.IntList[num * 18]; set_list_size_.invoke(field_info_vector3_size_, vertices_[front], boxed_num8); set_list_size_.invoke(field_info_vector3_size_, normals_[front], boxed_num8); set_list_size_.invoke(field_info_vector2_size_, uv2s_[front], boxed_num8); set_list_size_.invoke(field_info_int_size_, triangles_[front], boxed_num18); set_list_size_.invoke(field_info_vector2_size_, uvs_[front], boxed_num8); // sw.Stop(); // var plugin_time = sw.ElapsedTicks; // sw.Start(); // int num1 = // UnityPluginIF.ConvertArrayFromList(WATERSPLASH_MAX, // gc_handle_alive_table_items_.AddrOfPinnedObject(), // gc_handle_positions_items_.AddrOfPinnedObject(), // gc_handle_velocities_items_.AddrOfPinnedObject(), // gc_handle_uv2_list_items_.AddrOfPinnedObject(), // gc_handle_vertices_items_[front].AddrOfPinnedObject(), // gc_handle_normals_items_[front].AddrOfPinnedObject(), // gc_handle_uv2s_items_[front].AddrOfPinnedObject()); // object boxed_num40 = BoxingPool.IntList[num1*4]; // object boxed_num60 = BoxingPool.IntList[num1*6]; // set_list_size_.invoke_slower(field_info_vector3_size_, vertices_[front], boxed_num40); // set_list_size_.invoke_slower(field_info_vector3_size_, normals_[front], boxed_num40); // set_list_size_.invoke_slower(field_info_vector2_size_, uv2s_[front], boxed_num40); // set_list_size_.invoke_slower(field_info_int_size_, triangles_[front], boxed_num60); // set_list_size_.invoke_slower(field_info_vector2_size_, uvs_[front], boxed_num40); // sw.Stop(); // var plugin1_time = sw.ElapsedTicks; // sw.Start(); // int num2 = // UnityPluginIF.ConvertArrayFromList(WATERSPLASH_MAX, // gc_handle_alive_table_items_.AddrOfPinnedObject(), // gc_handle_positions_items_.AddrOfPinnedObject(), // gc_handle_velocities_items_.AddrOfPinnedObject(), // gc_handle_uv2_list_items_.AddrOfPinnedObject(), // gc_handle_vertices_items_[front].AddrOfPinnedObject(), // gc_handle_normals_items_[front].AddrOfPinnedObject(), // gc_handle_uv2s_items_[front].AddrOfPinnedObject()); // field_info_vector3_size_.SetValue(vertices_[front], num2*4); // field_info_vector3_size_.SetValue(normals_[front], num2*4); // field_info_vector2_size_.SetValue(uv2s_[front], num2*4); // field_info_int_size_.SetValue(triangles_[front], num2*6); // field_info_vector2_size_.SetValue(uvs_[front], num2*4); // sw.Stop(); // var plugin2_time = sw.ElapsedTicks; // sw.Start(); // vertices_[front].Clear(); // normals_[front].Clear(); // uv2s_[front].Clear(); // int idx = 0; // for (var i = 0; i < WATERSPLASH_MAX; ++i) { // if (alive_table_[i] != 0) { // for (var j = 0; j < 4; ++j) { // vertices_[front].Add(positions_[i]); // normals_[front].Add(velocities_[i]); // uv2s_[front].Add(uv2_list_[i]); // } // ++idx; // } // } // field_info_int_size_.SetValue(triangles_[front], idx*6); // field_info_vector2_size_.SetValue(uvs_[front], idx*4); // sw.Stop(); // var mono1_time = sw.ElapsedTicks; // sw.Start(); // vertices_[front].Clear(); // normals_[front].Clear(); // uv2s_[front].Clear(); // triangles_[front].Clear(); // uvs_[front].Clear(); // idx = 0; // for (var i = 0; i < WATERSPLASH_MAX; ++i) { // if (alive_table_[i] != 0) { // for (var j = 0; j < 4; ++j) { // vertices_[front].Add(positions_[i]); // normals_[front].Add(velocities_[i]); // uv2s_[front].Add(uv2_list_[i]); // } // triangles_[front].Add(idx*4+0); // triangles_[front].Add(idx*4+1); // triangles_[front].Add(idx*4+2); // triangles_[front].Add(idx*4+2); // triangles_[front].Add(idx*4+1); // triangles_[front].Add(idx*4+3); // uvs_[front].Add(new Vector2(0f, 0f)); // uvs_[front].Add(new Vector2(1f, 0f)); // uvs_[front].Add(new Vector2(0f, 1f)); // uvs_[front].Add(new Vector2(1f, 1f)); // ++idx; // } // } // sw.Stop(); // var mono2_time = sw.ElapsedTicks; // PerformanceMeter.Instance.setValue(0, (int)plugin_time); // PerformanceMeter.Instance.setValue(1, (int)plugin1_time); // PerformanceMeter.Instance.setValue(2, (int)plugin2_time); #else vertices_[front].Clear(); normals_[front].Clear(); uv2s_[front].Clear(); triangles_[front].Clear(); uvs_[front].Clear(); int idx = 0; for (var i = 0; i < WATERSPLASH_MAX; ++i) { if (alive_table_[i] != 0) { for (var j = 0; j < 8; ++j) { vertices_[front].Add(positions_[i]); normals_[front].Add(velocities_[i]); uv2s_[front].Add(uv2_list_[i]); } triangles_[front].Add(idx * 8 + 0); triangles_[front].Add(idx * 8 + 1); triangles_[front].Add(idx * 8 + 3); triangles_[front].Add(idx * 8 + 2); triangles_[front].Add(idx * 8 + 0); triangles_[front].Add(idx * 8 + 3); triangles_[front].Add(idx * 8 + 2); triangles_[front].Add(idx * 8 + 3); triangles_[front].Add(idx * 8 + 5); triangles_[front].Add(idx * 8 + 2); triangles_[front].Add(idx * 8 + 5); triangles_[front].Add(idx * 8 + 4); triangles_[front].Add(idx * 8 + 4); triangles_[front].Add(idx * 8 + 5); triangles_[front].Add(idx * 8 + 7); triangles_[front].Add(idx * 8 + 4); triangles_[front].Add(idx * 8 + 7); triangles_[front].Add(idx * 8 + 6); uvs_[front].Add(new Vector2(f3, 0f)); uvs_[front].Add(new Vector2(f7, 0f)); uvs_[front].Add(new Vector2(0f, f3)); uvs_[front].Add(new Vector2(1f, f3)); uvs_[front].Add(new Vector2(0f, f7)); uvs_[front].Add(new Vector2(1f, f7)); uvs_[front].Add(new Vector2(f3, 1f)); uvs_[front].Add(new Vector2(f7, 1f)); ++idx; } } // vertices_[front].Clear(); // normals_[front].Clear(); // uv2s_[front].Clear(); // int idx = 0; // for (var i = 0; i < WATERSPLASH_MAX; ++i) { // if (alive_table_[i] != 0) { // for (var j = 0; j < 4; ++j) { // vertices_[front].Add(positions_[i]); // normals_[front].Add(velocities_[i]); // uv2s_[front].Add(uv2_list_[i]); // } // ++idx; // } // } // field_info_triangles_size_.SetValue(triangles_[front], idx*6); // field_info_uvs_size_.SetValue(uvs_[front], idx*4); #endif }