-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathTexture2DHandler.cs
More file actions
67 lines (55 loc) · 2.38 KB
/
Texture2DHandler.cs
File metadata and controls
67 lines (55 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using UnityDataTools.Analyzer.SerializedObjects;
using UnityDataTools.FileSystem.TypeTreeReaders;
namespace UnityDataTools.Analyzer.SQLite.Handlers;
public class Texture2DHandler : ISQLiteHandler
{
SQLiteCommand m_InsertCommand;
bool m_skipCreateDatabase;
public Texture2DHandler(bool skipCreateDatabase)
{
m_skipCreateDatabase = skipCreateDatabase;
}
public void Init(SQLiteConnection db)
{
if (!m_skipCreateDatabase)
{
using var command = new SQLiteCommand(db);
command.CommandText = Properties.Resources.Texture2D;
command.ExecuteNonQuery();
}
m_InsertCommand = new SQLiteCommand(db);
m_InsertCommand.CommandText = "INSERT INTO textures(id, width, height, image_count, format, rw_enabled, mip_count) VALUES(@id, @width, @height, @image_count, @format, @rw_enabled, @mip_count)";
m_InsertCommand.Parameters.Add("@id", DbType.Int64);
m_InsertCommand.Parameters.Add("@width", DbType.Int32);
m_InsertCommand.Parameters.Add("@height", DbType.Int32);
m_InsertCommand.Parameters.Add("@image_count", DbType.Int32);
m_InsertCommand.Parameters.Add("@format", DbType.Int32);
m_InsertCommand.Parameters.Add("@rw_enabled", DbType.Int32);
m_InsertCommand.Parameters.Add("@mip_count", DbType.Int32);
}
public void Process(Context ctx, long objectId, RandomAccessReader reader, out string name, out long streamDataSize)
{
var texture2d = Texture2D.Read(reader);
m_InsertCommand.Parameters["@id"].Value = objectId;
m_InsertCommand.Parameters["@width"].Value = texture2d.Width;
m_InsertCommand.Parameters["@height"].Value = texture2d.Height;
m_InsertCommand.Parameters["@image_count"].Value = texture2d.ImageCount;
m_InsertCommand.Parameters["@format"].Value = texture2d.Format;
m_InsertCommand.Parameters["@rw_enabled"].Value = texture2d.RwEnabled;
m_InsertCommand.Parameters["@mip_count"].Value = texture2d.MipCount;
m_InsertCommand.ExecuteNonQuery();
name = texture2d.Name;
streamDataSize = texture2d.StreamDataSize;
}
public void Finalize(SQLiteConnection db)
{
}
void IDisposable.Dispose()
{
m_InsertCommand.Dispose();
}
}