Exemplo n.º 1
0
 public void Inject(LuaTable self)
 {
     for (int i = 0; i < injections.Length; i++)
     {
         Injection pair = injections[i];
         if (pair.key.Contains("."))
         {
             self.SetInPath(pair.key, pair.value);
         }
         else
         {
             self.Set(pair.key, pair.value);
         }
     }
 }
Exemplo n.º 2
0
        protected void DrawInjectionListElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect.y += 1;
            SerializedProperty pair     = injectionList.serializedProperty.GetArrayElementAtIndex(index);
            SerializedProperty key      = pair.FindPropertyRelative("key");
            SerializedProperty value    = pair.FindPropertyRelative("value");
            SerializedProperty typeName = pair.FindPropertyRelative("typeName");

            if (string.IsNullOrEmpty(typeName.stringValue))
            {
                typeName.stringValue = "UnityEngine.Object";
            }
            Type type = Injection.GetType(typeName.stringValue);

            EditorGUI.LabelField(new Rect(rect.x, rect.y, 20, EditorGUIUtility.singleLineHeight), index.ToString("00"));
            float width = (rect.width - 20) / 3 - 5;

            if (GUI.Button(new Rect(rect.x + 25, rect.y, width, EditorGUIUtility.singleLineHeight), type.Name))
            {
                DrawTypeMenu(delegate(object name) { typeName.stringValue = (string)name; });
            }
            EditorGUI.PropertyField(new Rect(rect.x + 30 + width, rect.y, width, EditorGUIUtility.singleLineHeight), key, GUIContent.none);
            value.objectReferenceValue = EditorGUI.ObjectField(new Rect(rect.x + 35 + width * 2, rect.y, width, EditorGUIUtility.singleLineHeight), value.objectReferenceValue, type, true);
        }