Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
baba-s committed Mar 27, 2019
1 parent 474c9d5 commit e468166
Show file tree
Hide file tree
Showing 35 changed files with 1,948 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/.gitignore
@@ -0,0 +1,33 @@
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Visual Studio 2015 cache directory
/.vs/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb

# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
8 changes: 8 additions & 0 deletions app/Assets/iPhoneXSafeAreaDrawer.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/Assets/iPhoneXSafeAreaDrawer/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions app/Assets/iPhoneXSafeAreaDrawer/Editor/iPhoneXSafeAreaDrawer.cs
@@ -0,0 +1,99 @@
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace iPhoneXSafeAreaDrawerEditor
{
[InitializeOnLoad]
public static class iPhoneXSafeAreaDrawer
{
private static Texture m_portraitImage;
private static Texture m_landscapeImage;
private static iPhoneXSafeAreaDrawerSettings m_settings;

private static Texture portraitImage
{
get
{
if ( m_portraitImage == null )
{
var guid = AssetDatabase
.FindAssets( "iPhoneXSafeAreaDrawer-portrait" )
.FirstOrDefault()
;

var path = AssetDatabase.GUIDToAssetPath( guid );

m_portraitImage = AssetDatabase.LoadAssetAtPath<Texture>( path );
}
return m_portraitImage;
}
}

private static Texture landscapeImage
{
get
{
if ( m_landscapeImage == null )
{
var guid = AssetDatabase
.FindAssets( "iPhoneXSafeAreaDrawer-landscape" )
.FirstOrDefault()
;

var path = AssetDatabase.GUIDToAssetPath( guid );

m_landscapeImage = AssetDatabase.LoadAssetAtPath<Texture>( path );
}
return m_landscapeImage;
}
}

private static iPhoneXSafeAreaDrawerSettings settings
{
get
{
if ( m_settings == null )
{
m_settings = AssetDatabase
.FindAssets( "t:iPhoneXSafeAreaDrawerSettings" )
.Select( c => AssetDatabase.GUIDToAssetPath( c ) )
.Select( c => AssetDatabase.LoadAssetAtPath<iPhoneXSafeAreaDrawerSettings>( c ) )
.FirstOrDefault()
;
}
return m_settings;
}
}

static iPhoneXSafeAreaDrawer()
{
// Unity エディタ起動時にゲームオブジェクトを生成する場合は
// 1 フレーム処理を遅らせる必要がある
EditorApplication.delayCall += Initialize;
}

private static void Initialize()
{
var obj = GameObject.Find( "OnGUIHandler" );

if ( obj == null )
{
obj = new GameObject( "OnGUIHandler", typeof( OnGUIHandler ) );
obj.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
}

var handler = obj.GetComponent<OnGUIHandler>();
handler.mOnGUI = OnGUI;
}

private static void OnGUI()
{
if ( !settings.IsEnable ) return;

var img = settings.IsPortrait ? portraitImage : landscapeImage;
var pos = new Rect( 0, 0, Screen.width, Screen.height );
GUI.DrawTexture( pos, img );
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2b4a4c2bb01403b4a86882fb3ac359e2, type: 3}
m_Name: iPhoneXSafeAreaDrawerSettings
m_EditorClassIdentifier:
m_isEnable: 0
m_isPortrait: 0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/Assets/iPhoneXSafeAreaDrawer/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions app/Assets/iPhoneXSafeAreaDrawer/Scripts/OnGUIHandler.cs
@@ -0,0 +1,19 @@
using System;
using UnityEngine;

namespace iPhoneXSafeAreaDrawerEditor
{
/// <summary>
/// OnGUI が呼び出されるタイミングでイベントを実行するコンポーネント
/// </summary>
[ExecuteInEditMode]
public sealed class OnGUIHandler : MonoBehaviour
{
public Action mOnGUI { private get; set; }

private void OnGUI()
{
mOnGUI?.Invoke();
}
}
}

0 comments on commit e468166

Please sign in to comment.