コード例 #1
0
ファイル: FileManager.cs プロジェクト: dreadcrumb/Derpanizer
        private GameObject InstantiateImage(StuffToSaveClass file)
        {
            var obj = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Image.prefab", typeof(GameObject));
            var loc = file.Location.ToVector3();

            if (!_loaded)
            {
                loc.y += 1;
            }
            obj = Instantiate(obj, loc, file.Rotation.ToQuaternion());
            obj.GetComponent <PictureResizer>().InitImage(file.Info.ToString());
            return(obj);
        }
コード例 #2
0
ファイル: FileManager.cs プロジェクト: dreadcrumb/Derpanizer
        private void InstantiateFile(StuffToSaveClass file)
        {
            GameObject obj;

            switch (file.Info.Extension)
            {
            case ".png":
            case ".jpg":
            case ".jpeg":
                obj = InstantiateImage(file);
                break;

            case ".txt":
            case ".doc":
            case "pdf":
            case "docx":
            case "rtf":
                obj = Instantiate(
                    (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Textdocument.prefab", typeof(GameObject)), file.Location.ToVector3(), file.Rotation.ToQuaternion());
                break;

            default:
                obj = Instantiate(
                    (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/File.prefab", typeof(GameObject)), file.Location.ToVector3(), file.Rotation.ToQuaternion());
                break;
            }

            obj.AddComponent <FileObject>();
            obj.GetComponent <FileObject>().Init(file.Info);

            //file.Obj = obj;
            _objList.Add(obj);

            // Set HoverText
            var hover = Instantiate(
                (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/HoverT.prefab", typeof(GameObject)),
                obj.transform.position, file.Rotation.ToQuaternion());
            //hover.GetComponent<HoverText>().SetTarget(obj.transform);
            //hover.GetComponent<HoverText>().GetComponent<GUIText>().text = file.Info.Name.Split(Const.Const.BACKSLASH.ToCharArray()).Last();
        }