P4 -> GitHub sync.
This commit is contained in:
max
2020-11-01 03:54:32 +01:00
parent e6b8bcef3c
commit 1165a4e4a8
124 changed files with 15569 additions and 3 deletions

View File

@ -0,0 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_WEBGL
using System.Text;
using System.Runtime.InteropServices;
#endif
namespace TextureCombiner
{
public class TextureHandlerWeb : TextureHandler
{
#if UNITY_WEBGL
protected override void OnEnable()
{
base.OnEnable();
}
protected override void OnDisable()
{
base.OnDisable();
}
protected override void Load()
{
UploadFile(this.gameObject.name, "OnLoadTexturesWWW", ".png, .jpg, .jpeg", true);
}
public void OnLoadTexturesWWW(string path)
{
string[] paths = path.Split(',');
StartCoroutine(LoadTexturesWWW(paths));
}
public IEnumerator LoadTexturesWWW(string[] paths)
{
if (paths.Length != 0)
{
foreach (string p in paths)
{
Debug.Log(p);
// Load Image.
var loader = new WWW(p);
yield return loader;
m_textureCombiner.LoadTextureSlot(loader.texture);
}
}
}
public void OnSaveTextureWWW()
{
Debug.Log("OnSaveTextureWWW");
}
[DllImport("__Internal")]
private static extern void UploadFile(string gameObjectName, string methodName, string filter, bool multiple);
[DllImport("__Internal")]
private static extern void DownloadFile(string gameObjectName, string methodName, string filename, byte[] byteArray, int byteArraySize);
protected override void Save(string name)
{
base.Save(name);
}
protected override void SaveTexture(string path, byte[] bytes)
{
DownloadFile(this.gameObject.name, "OnSaveTextureWWW", path, bytes, bytes.Length);
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 978cb2b8bd47605408384d0375fe2e82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,114 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_STANDALONE_WIN
using B83.Win32;
#endif
#if UNITY_STANDALONE
using SFB;
#endif
namespace TextureCombiner
{
public class TextureHandlerWin : TextureHandler
{
#if UNITY_STANDALONE
protected override void OnEnable()
{
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
UnityDragAndDropHook.InstallHook();
UnityDragAndDropHook.OnDroppedFiles += LoadDropPaths;
#endif
base.OnEnable();
}
protected override void OnDisable()
{
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
UnityDragAndDropHook.OnDroppedFiles -= LoadDropPaths;
UnityDragAndDropHook.UninstallHook();
#endif
base.OnDisable();
}
protected override void Load()
{
// Open file with filter
var extensions = new[]
{
new ExtensionFilter("Image Files", "png", "jpg", "jpeg" )
};
StandaloneFileBrowser.OpenFilePanelAsync("Open File", "", extensions, true, LoadPaths);
}
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
private void LoadDropPaths(List<string> paths, POINT aPos)
{
List<string> outPaths = new List<string>();
foreach (string p in paths)
{
var fi = new System.IO.FileInfo(p);
var ext = fi.Extension.ToLower();
if (ext == ".png" || ext == ".jpg" || ext == ".jpeg")
{
outPaths.Add(p);
}
}
if(outPaths.Count > 0)
{
LoadPaths(outPaths.ToArray());
}
}
#endif
private void LoadPaths(string[] paths)
{
if(paths.Length != 0)
{
LoadTextures(paths);
}
}
private void LoadTextures(string[] paths)
{
if(paths.Length != 0)
{
foreach (string p in paths)
{
Debug.Log(p);
// Load Image.
var bytes = System.IO.File.ReadAllBytes(p);
Texture2D texture = new Texture2D(2, 2);
texture.hideFlags = HideFlags.HideAndDontSave;
texture.LoadImage(bytes);
texture.Apply();
m_textureCombiner.LoadTextureSlot(texture);
}
}
}
protected override void Save(string name)
{
// Open file with filter
var extensions = new[]
{
new ExtensionFilter("Image Files", "png")
};
StandaloneFileBrowser.SaveFilePanelAsync("Save file", "", name, extensions, base.Save);
}
protected override void SaveTexture(string path, byte[] bytes)
{
System.IO.File.WriteAllBytes(path, bytes);
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a52e2fdc38fe1f47ba34b6f5818afca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: