Skip to content

Commit 3215b60

Browse files
authored
Merge pull request #3 from ADONE-Games/feature/RenderTexture_Create
RenderTextureの生成・取得周りの作成
2 parents c303645 + 244c61b commit 3215b60

20 files changed

Lines changed: 536 additions & 324 deletions

Assets/ResolutionCalcCache/Editor/ProjectSettingData.cs

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ public void OnGUI()
318318
{
319319
var activeData = ResolutionDataList[_resolutionDataEditList.ActiveIndex];
320320
var activeCategory = ResolutionCategoryList[_resolutionCategoryEditList.ActiveIndex];
321-
var (width, height, aspect, orientation, fitDirection) = ViewGUILayout( activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Width, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Height, activeData.FitDirection );
321+
var (width, height, aspect, depth, format, orientation, fitDirection) = ViewGUILayout( activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Width, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Height, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Depth, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Format, activeData.FitDirection );
322322

323323
if( check.changed )
324324
{
325325
Undo.RecordObject( this, "SetResolutionData" );
326326

327-
activeData.SetSize( activeCategory, width, height );
327+
activeData.SetSize( activeCategory, width, height, depth, format );
328328
activeData.SetFitDirection( fitDirection );
329329
EditorUtility.SetDirty( this );
330330
}
@@ -334,7 +334,7 @@ public void OnGUI()
334334
using( new EditorGUILayout.VerticalScope( "helpBox" ) )
335335
{
336336
EditorGUILayout.Space( 30 );
337-
ViewGUILayout( activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Height, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Width, activeData.FitDirection == FitDirection.Horizontal ? FitDirection.Vertical : FitDirection.Horizontal );
337+
ViewGUILayout( activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Height, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Width, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Depth, activeData.ResolutionSizeDataList[_resolutionCategoryEditList.ActiveIndex].Format, activeData.FitDirection == FitDirection.Horizontal ? FitDirection.Vertical : FitDirection.Horizontal );
338338
EditorGUILayout.Space( 10 );
339339
}
340340
}
@@ -349,7 +349,7 @@ public void OnGUI()
349349
}
350350

351351

352-
private ( int width, int height, float aspect, ScreenOrientation orientation, FitDirection fitDirection ) ViewGUILayout( int width, int height, FitDirection fitDirection )
352+
private ( int width, int height, float aspect, int depth, RenderTextureFormat format, ScreenOrientation orientation, FitDirection fitDirection ) ViewGUILayout( int width, int height, int depth, RenderTextureFormat format, FitDirection fitDirection )
353353
{
354354
var result = Editor.ResolutionSizeData.SizeCalculation( width, height );
355355

@@ -377,6 +377,16 @@ public void OnGUI()
377377
GUILayout.FlexibleSpace();
378378
result.height = EditorGUILayout.IntField( "Height", result.height, GUILayout.Width( 500 ) );
379379
}
380+
using( new EditorGUILayout.HorizontalScope() )
381+
{
382+
GUILayout.FlexibleSpace();
383+
depth = EditorGUILayout.IntPopup( depth, new[] { "0", "16", "24" }, new[] { 0, 16, 24 }, GUILayout.Width( 50 ) );
384+
}
385+
using( new EditorGUILayout.HorizontalScope() )
386+
{
387+
GUILayout.FlexibleSpace();
388+
format = (RenderTextureFormat)EditorGUILayout.EnumPopup( format, GUILayout.Width( 100 ) );
389+
}
380390

381391
using( new EditorGUI.DisabledGroupScope( true ) )
382392
using( new EditorGUILayout.HorizontalScope() )
@@ -395,7 +405,7 @@ public void OnGUI()
395405
}
396406

397407

398-
return ( result.width, result.height, result.aspect, result.orientation, fitDirection );
408+
return ( result.width, result.height, result.aspect, depth, format, result.orientation, fitDirection );
399409
}
400410

401411
private ResolutionDataEditList GetResolutionDataEditList()
@@ -404,7 +414,7 @@ private ResolutionDataEditList GetResolutionDataEditList()
404414
{
405415
SeveObject = this,
406416
ResolutionDataList = ResolutionDataList,
407-
AddItem = () => new ResolutionData( ResolutionCategoryList ,1080, 1920 )
417+
AddItem = () => new ResolutionData( ResolutionCategoryList ,1080, 1920, 0, RenderTextureFormat.ARGB32 )
408418
};
409419
}
410420

@@ -418,7 +428,7 @@ private ResolutionCategoryEditList GetResolutionCategoryEditList()
418428
categoryList.Add( string.Empty );
419429
foreach( var data in ResolutionDataList )
420430
{
421-
data.SetSize( string.Empty, 1080, 1020 );
431+
data.SetSize( string.Empty, 1080, 1020, 0, RenderTextureFormat.ARGB32 );
422432
}
423433
},
424434
RemoveItem = activeIndex => {
@@ -485,15 +495,15 @@ internal class ResolutionData
485495

486496
public FitDirection FitDirection;
487497

488-
public ResolutionData( string categoryName, int width, int height )
498+
public ResolutionData( string categoryName, int width, int height, int depth, RenderTextureFormat format )
489499
{
490-
SetSize( categoryName, width, height );
500+
SetSize( categoryName, width, height, depth, format );
491501
}
492-
public ResolutionData( List<string> categoryNames, int width, int height )
502+
public ResolutionData( List<string> categoryNames, int width, int height, int depth, RenderTextureFormat format )
493503
{
494504
foreach( var categoryName in categoryNames )
495505
{
496-
SetSize( categoryName, width, height );
506+
SetSize( categoryName, width, height, depth, format );
497507
}
498508
}
499509

@@ -507,7 +517,7 @@ public void SetCategoryName( int index, string categoryName )
507517
ResolutionSizeDataList[ index ].SetCategoryName( categoryName );
508518
}
509519

510-
public void SetSize( string categoryName, int width, int height )
520+
public void SetSize( string categoryName, int width, int height, int depth, RenderTextureFormat format )
511521
{
512522
ResolutionSizeDataList ??= new List<ResolutionSizeData>();
513523

@@ -516,13 +526,13 @@ public void SetSize( string categoryName, int width, int height )
516526
if( !ResolutionSizeDataList[ i ].CategoryName.Equals( categoryName ) )
517527
continue;
518528

519-
ResolutionSizeDataList[ i ].SetSize( width, height );
529+
ResolutionSizeDataList[ i ].SetSize( width, height, depth, format );
520530
return;
521531
}
522532

523533
if( !ResolutionSizeDataList.Any( data => data.CategoryName == categoryName ) )
524534
{
525-
ResolutionSizeDataList.Add( new ResolutionSizeData( categoryName, width, height ) );
535+
ResolutionSizeDataList.Add( new ResolutionSizeData( categoryName, width, height, depth, format ) );
526536
}
527537
}
528538

@@ -559,14 +569,18 @@ public class ResolutionSizeData
559569
public int Width;
560570
public int Height;
561571

572+
[NonSerialized]
573+
public float Aspect;
574+
575+
public int Depth;
576+
577+
public RenderTextureFormat Format;
578+
562579
[NonSerialized]
563580
public float WidthAspectProportional;
564581
[NonSerialized]
565582
public float HeightAspectProportional;
566583

567-
[NonSerialized]
568-
public float Aspect;
569-
570584
[NonSerialized]
571585
public ScreenOrientation Orientation;
572586

@@ -576,27 +590,33 @@ public ResolutionSizeData( string categoryName )
576590
CategoryName = categoryName;
577591
}
578592

579-
public ResolutionSizeData( string categoryName, int width, int height )
593+
public ResolutionSizeData( string categoryName, int width, int height, int depth, RenderTextureFormat format )
580594
{
581-
SetSize( categoryName, width, height );
595+
SetSize( categoryName, width, height, depth, format );
582596
}
583597

584598
public void SetCategoryName( string categoryName )
585599
{
586600
CategoryName = categoryName;
587601
}
602+
public void SetRenderTextureFormat( RenderTextureFormat format )
603+
{
604+
Format = format;
605+
}
588606

589-
public void SetSize( string categoryName, int width, int height )
607+
public void SetSize( string categoryName, int width, int height, int depth, RenderTextureFormat format )
590608
{
591609
SetCategoryName( categoryName );
592-
SetSize( width, height );
610+
SetSize( width, height, depth, format );
593611
}
594-
public void SetSize( int width, int height )
612+
public void SetSize( int width, int height, int depth, RenderTextureFormat format )
595613
{
596614
var result = SizeCalculation( width, height );
597615

598616
Width = result.width;
599617
Height = result.height;
618+
Depth = depth;
619+
SetRenderTextureFormat( format );
600620

601621
WidthAspectProportional = result.widthAspectProportional;
602622
HeightAspectProportional = result.heightAspectProportional;
@@ -608,7 +628,7 @@ public void SetSize( int width, int height )
608628

609629
public void SetSize()
610630
{
611-
SetSize( Width, Height );
631+
SetSize( Width, Height, Depth, Format );
612632
}
613633

614634
public static ( int width, int height, float aspect, float widthAspectProportional, float heightAspectProportional, ScreenOrientation orientation ) SizeCalculation( int width, int height )
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ResolutionDataProc.Append(
2+
(int)ResolutionLevel.#LEVEL#,
3+
new[] {
4+
#DATACLASS#
5+
} );

Assets/ResolutionCalcCache/Editor/ResolutionDataProcAppendTemplate.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
///////////////////////////////////////////////////////////////////////////////////////////
2-
// This file is automatically generated.
3-
// Modifying it is not recommended.
4-
///////////////////////////////////////////////////////////////////////////////////////////
5-
using ADONEGames.ResolutionCalcCache;
6-
7-
namespace #NAMESPACE#
8-
{
9-
/// <inheritdoc cref="IResolutionData"/>
10-
public struct #CLASS# : IResolutionData
11-
{
12-
readonly IResolutionSizeData[] IResolutionData.ResolutionSizeDatas => new IResolutionSizeData[] { #SIZEDATA# };
13-
14-
/// <inheritdoc />
15-
readonly FitDirection IResolutionData.FitDirection => FitDirection.#FitDirection#;
16-
17-
#SIZEDATACLASS#
18-
}
19-
}
1+
new ResolutionData( new[] { #SIZEDATACLASS# }, FitDirection.#FitDirection# ),

0 commit comments

Comments
 (0)