public static int GetOffset(SceneNames value) { var type = value.GetType(); var field = type.GetField(value.ToString(), BindingFlags.Static | BindingFlags.Public); var attributes = field.GetCustomAttributes(typeof(CameraXOffsetAttribute), false); var attribute = attributes[0] as CameraXOffsetAttribute; var offset = attribute.Offset; return offset; }