using System;
using System.Collections.Generic;
using System.IO;
using Kasizuki;
using UnityEngine;

public class VRIKGeneralObjectSetter : MonoBehaviour
{
	private NGUIWindow window
	{
		get
		{
			return this.m_Window = (this.m_Window ?? base.GetComponent<NGUIWindow>());
		}
	}

	private void Awake()
	{
		this.window.OnOpen = new Action(this.OnOpen);
		this.m_FullPathList = OvrIK.UpdateGeneralModelFileList();
		this.CreateList();
		UIButton component = UTY.GetChildObject(this.window.gameObject, "data list window/button reload", false).GetComponent<UIButton>();
		UIButton component2 = UTY.GetChildObject(this.window.gameObject, "data list window/button delete", false).GetComponent<UIButton>();
		EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.OnClickReload));
		EventDelegate.Add(component2.onClick, new EventDelegate.Callback(this.OnClickDelete));
	}

	private void OnOpen()
	{
	}

	private void CreateList()
	{
		List<string> fullPathList = this.m_FullPathList;
		this.m_WindowListData.Show<string, UIButton>(fullPathList, delegate(int index, string path, UIButton button)
		{
			UILabel componentInChildren = button.GetComponentInChildren<UILabel>();
			if (componentInChildren != null)
			{
				componentInChildren.text = Path.GetFileName(path);
			}
			EventDelegate.Add(button.onClick, delegate()
			{
				OvrIK.LoadGeneralModelFile(path);
			});
		});
		Debug.Log("[VRIK_GeneralObjectSetter] 一般オブジェクト一覧の読み込み完了\n要素数 : " + fullPathList.Count);
	}

	private void OnClickReload()
	{
		this.m_FullPathList = OvrIK.UpdateGeneralModelFileList();
		this.CreateList();
	}

	private void OnClickDelete()
	{
		OvrIK.DestroyGeneralModelAll();
	}

	[SerializeField]
	private ListViewerWindow m_WindowListData;

	private NGUIWindow m_Window;

	private List<string> m_FullPathList = new List<string>();
}
