Tanoda
GameObjectExtension.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4namespace Es.InkPainter
5{
6 public static class GameObjectExtension
7 {
14 public static InkCanvas AddInkCanvas(this GameObject gameObject, List<InkCanvas.PaintSet> paintDatas)
15 {
16 if (paintDatas == null || paintDatas.Count == 0)
17 {
18 //PaintDatas is null or empty.
19 Debug.LogError("Parameter is null or empty.");
20 return null;
21 }
22
23 var active = gameObject.activeSelf;
24 gameObject.SetActive(false);
25 var inkCanvas = gameObject.AddComponent<InkCanvas>();
26 if (inkCanvas == null)
27 {
28 //Add component error
29 Debug.LogError("Could not attach InkCanvas to GameObject.");
30 return null;
31 }
32
33 //Init canvas component.
34 inkCanvas.OnCanvasAttached += canvas => { canvas.PaintDatas = paintDatas; };
35
36 gameObject.SetActive(active);
37 return inkCanvas;
38 }
39
46 public static InkCanvas AddInkCanvas(this GameObject gameObject, InkCanvas.PaintSet paintData)
47 {
48 if (paintData == null)
49 {
50 Debug.LogError("Parameter is null or empty.");
51 return null;
52 }
53
54 return gameObject.AddInkCanvas(new List<InkCanvas.PaintSet> {paintData});
55 }
56 }
57}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19