Commit 14d342eb authored by Martin Finkel's avatar Martin Finkel
Browse files

remove uniClipboard

parent cd08c48b
//
// Clipper.m
// Clip
//
// Created by sanuki.wataru on 2015/01/15.
// Copyright (c) 2015年 sanuki.wataru. All rights reserved.
//
char *MakeStringCpy(const char* string);
void SetText_(const char* c){
[UIPasteboard generalPasteboard].string = [NSString stringWithCString: c encoding:NSUTF8StringEncoding];
}
char *GetText_(){
return MakeStringCpy([[UIPasteboard generalPasteboard].string UTF8String]);
}
char *MakeStringCpy(const char* string){
if (string == NULL)
return NULL;
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
\ No newline at end of file
using UnityEngine;
using System.Runtime.InteropServices;
public class UniClipboard
{
static IBoard _board;
static IBoard board{
get{
if (_board == null) {
#if UNITY_EDITOR
_board = new EditorBoard();
#elif UNITY_ANDROID
_board = new AndroidBoard();
#elif UNITY_IOS
_board = new IOSBoard ();
#endif
}
return _board;
}
}
public static void SetText(string str){
Debug.Log ("SetText");
board.SetText (str);
}
public static string GetText(){
return board.GetText ();
}
}
interface IBoard{
void SetText(string str);
string GetText();
}
class EditorBoard : IBoard {
public void SetText(string str){
GUIUtility.systemCopyBuffer = str;
}
public string GetText(){
return GUIUtility.systemCopyBuffer;
}
}
#if UNITY_IOS
class IOSBoard : IBoard {
[DllImport("__Internal")]
static extern void SetText_ (string str);
[DllImport("__Internal")]
static extern string GetText_();
public void SetText(string str){
if (Application.platform != RuntimePlatform.OSXEditor) {
SetText_ (str);
}
}
public string GetText(){
return GetText_();
}
}
#endif
#if UNITY_ANDROID
class AndroidBoard : IBoard {
AndroidJavaClass cb = new AndroidJavaClass("jp.ne.donuts.uniclipboard.Clipboard");
public void SetText(string str){
Debug.Log ("Set Text At AndroidBoard: " + str);
cb.CallStatic ("setText", str);
}
public string GetText(){
return cb.CallStatic<string> ("getText");
}
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment