Skip to content

Instantly share code, notes, and snippets.

NSURL *downloadURL = [NSURL URLWithString:path];
NSURLRequest *request = [NSURLRequest requestWithURL:downloadURL];
self.downloadTask = [self.session downloadTaskWithRequest:request];
[self.downloadTask resume];
- (BOOL) printExistFile:(NSString*) targetFilePath
{
// 【1. ファイルまでのパスを作成】
// ダウンロードした画像が格納されたディレクトリパス取得(適宜変更してください)
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// ファイルパスの作成
NSString *filePath = [[dirPaths objectAtIndex:0] stringByAppendingPathComponent:targetFilePath];
// 【2. NSFileManagerを取得】
// 【1. ファイルまでのパスを作成】
// ダウンロードした画像が格納されたディレクトリパス取得(適宜変更してください)
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// ファイルパスの作成
NSString *filePath = [[dirPaths objectAtIndex:0] stringByAppendingPathComponent:@"img.png"];
// 【2. NSFileManagerを取得】
NSFileManager *fileManager = [NSFileManager defaultManager];
@baobao
baobao / HelloWorldDOTween.cs
Created January 24, 2021 21:32
初めてのDOTween
using System.Collections;
using UnityEngine;
using DG.Tweening;
public class HelloWorldDOTween : MonoBehaviour
{
void Start()
{
transform.DOLocalMove(new Vector3(10f, 0, 0), 1f);
}
@baobao
baobao / UIToolkit_DragAndDropTest.cs
Created January 6, 2021 08:51
【Unity】UI ToolkitのDragAndDropサンプル
using UnityEngine;
using UnityEngine.UIElements;
/// <summary>
/// DragAndDrop Sample
/// </summary>
[RequireComponent(typeof(UIDocument))]
public class UIToolkit_DragAndDropTest : MonoBehaviour
{
private Vector2 _dragOffset;
@baobao
baobao / UIToolkit_MouseDownUpTest.cs
Last active January 29, 2022 08:58
UI Toolkitサンプル:MouseDown・MouseUpショートコード
using UnityEngine;
using UnityEngine.UIElements;
// 解説Qiita記事 : https://qiita.com/ohbashunsuke/items/ae1da96e582aef734eee
[RequireComponent(typeof(UIDocument))]
public class UIToolkit_MouseDownUpTest : MonoBehaviour
{
void OnEnable()
{
var document = GetComponent<UIDocument>();
// _visualEffect.SendEvent("OnPlay"); と同じ
// _visualEffect.SendEvent(VisualEffectAsset.PlayEventName); と同じ
_visualEffect.SendEvent(VisualEffectAsset.PlayEventID);
var id = Shader.PropertyToID("イベント名");
_visualEffect.SendEvent(id);
/// <summary>
/// <para>The default name ID of the play event.</para>
/// </summary>
public static readonly int PlayEventID = Shader.PropertyToID("OnPlay");
/// <summary>
/// <para>The default name ID of the stop event.</para>
/// </summary>
public static readonly int StopEventID = Shader.PropertyToID("OnStop");
// _visualEffect.SendEvent("OnPlay");と同じ
_visualEffect.SendEvent(VisualEffectAsset.PlayEventName);