質問編集履歴

3

追記

2016/11/14 14:08

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -99,3 +99,99 @@
99
99
 
100
100
 
101
101
  上記のコードではデバッグはとれていて、iの値は変化しています。
102
+
103
+
104
+
105
+ ###追記。
106
+
107
+
108
+
109
+ staticな変数の場合。
110
+
111
+
112
+
113
+ ```C#
114
+
115
+ using UnityEngine;
116
+
117
+ using System.Collections;
118
+
119
+ using UnityEditor;
120
+
121
+
122
+
123
+ public class Sample : MonoBehaviour {
124
+
125
+
126
+
127
+ [SerializeField]
128
+
129
+ //int i = 100;
130
+
131
+ //staticな変数にしてみる。
132
+
133
+ static int j = 50;
134
+
135
+
136
+
137
+ [CustomEditor(typeof(Sample))]
138
+
139
+ public class SampleInspector : Editor
140
+
141
+ {
142
+
143
+
144
+
145
+ //SerializedProperty spi;
146
+
147
+ SerializedProperty spj;
148
+
149
+
150
+
151
+ void OnEnable()
152
+
153
+ {
154
+
155
+ // SerializedProperty取得
156
+
157
+ //spi = serializedObject.FindProperty( "i" );
158
+
159
+ spj = serializedObject.FindProperty( "j" );
160
+
161
+ }
162
+
163
+
164
+
165
+ public override void OnInspectorGUI()
166
+
167
+ {
168
+
169
+ // 値の更新
170
+
171
+ serializedObject.Update();
172
+
173
+
174
+
175
+ base.OnInspectorGUI();
176
+
177
+ if (GUILayout.Button("ボタン", GUILayout.Width(80f))) {
178
+
179
+ //spi.intValue +=10;
180
+
181
+ spj.intValue += 10;
182
+
183
+ }
184
+
185
+
186
+
187
+ // 値の反映
188
+
189
+ serializedObject.ApplyModifiedProperties();
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ ```

2

追記

2016/11/14 14:08

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -98,4 +98,4 @@
98
98
 
99
99
 
100
100
 
101
- デバッグはとれていて、iの値は変化しています。
101
+ 上記のコードではデバッグはとれていて、iの値は変化しています。

1

追記

2016/11/11 11:20

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -95,3 +95,7 @@
95
95
  }
96
96
 
97
97
  ```
98
+
99
+
100
+
101
+ デバッグはとれていて、iの値は変化しています。